-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative margin in dimension controls #32644
Comments
Actually you can do it by passing
It is not explained in Readme but i can able to find it when searching inside core files |
Does anyone know if there are plans to implement this? Negative margins are a very common and useful layout tool that seems should be enabled by default for the core margin control. |
Hallo! Trying to work with FSE and this is a serious serious oversight. We need to be able to set negative margins, it's a very common technique. |
I am not sure how this would affect the blockgap? |
+1 to adding negative margins. I just found a case in the wild where this would have been very useful. |
I believe a negative margin value would affect the blockgap just like a positive margin does and override the blockgap css for that particular block. |
+1 Negative margin is essential for design and layout building |
+1 Negative margin allowing for overlapping elements is essential. |
+1 I need it for a design I'm currently building. |
Reopening this one because #40464 is getting reverted. |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 The is essential to designing layouts, the recent revert broke a few sites of mine. |
This might be possible by using "spacing presets" in theme.json. I have not tested it. |
Where can I find the specific code? |
Thanks. --wp-priset--spacing-size--minus1: -1 Before testing. |
This is definitely needed. I was trying to show a client how to add margins to a block and could not add negative margins when they asked about overlapping a block on top of another. This is a limitation for block themes in being able to achieve certain layouts |
That’s how I do it. You could also combine it with the 2nd Color 0% opacity and a cover block (nested) to create interesting effects with images. But there is sometime a glitch of 1 pixel. |
Plus one for this. |
Plus one for this issue. I needed to use negative margins on a recent client project and had to revert to customize.php to add custom CSS and make it work. It would be nice if you could just enter a negative margin in the site editor. |
+1 |
+1 soooohoohooho many people are gonna be totally stoked when this comes out. |
I write a snippets to put in your "custm snippets" plugin : add_action('admin_footer', 'remove_min_value_inline_script');
function remove_min_value_inline_script() {
echo '<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
mutation.addedNodes.forEach(function(node) {
if (node.querySelectorAll) {
node.querySelectorAll("input[min=\'0\']").forEach(function(input) {
input.removeAttribute("min");
});
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
</script>';
} And It's work perfectly :) |
thats a very very generic code. i would at least add this to the selector: |
I adapted the code : add_action('admin_footer', 'remove_min_value_inline_script');
function remove_min_value_inline_script() {
echo '<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes.length) {
mutation.addedNodes.forEach(function(node) {
if (node.querySelectorAll) {
node.querySelectorAll(".spacing-sizes-control input[min=\'0\']").forEach(function(input) {
input.removeAttribute("min");
});
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
</script>';
} |
+1 It would realy be very helpful!! |
+1 |
+1 Adding a note that fixed (px, em, etc.) values shouldn't be the only option. I'd like to see the spacing scale allow for negative clamp/min/max values as well. From Andrews screenshots you can see how the padding on the red Group block could have a value that uses clamp from the spacing scale. Adding a set px/em value for negative margin will not scale accordingly along with the Group and very likely cause unintended overlap issues. We've used custom margin settings for a while (before they were in core) with this approach and it's proven to work fairly well. |
Big +1 to this. Reviewing a client design right now and I really could use this functionality. I will probably wind up home-baking something |
We need this asap! Why it is not implemented by default though? |
+1! Is there an update on this for 2024? |
Need it! Please! Now I'm adding it with a css class 😔 |
+1 so that we don't need to write custom css classes. |
OMG, it still doesn't have negative margin? |
+1 topic started from 2021 |
+1 |
2 similar comments
+1 |
+1 |
As this is being explored in this initial PR (#60347), I want to share some UX considerations. Specifically, I want to note that there needs to be a pause/stop point before going to negative values when using either the slider or the ability to drag up/down to change controls as shown below: negative.margin.mp4Right now, with the current PR that is meant to be a small start towards solving this, you can quickly slide past the 0 and it would go a long way to have a "sticky" point at 0 as it's a common action to try to 0 out values to reset something. I'm aware, I can go to the three dot menu to reset but this would keep the more visible options useful to reset while also allowing new functionality. |
What problem does this address?
It is not possible to use negative margins in the margin control.
What is your proposed solution?
If negative margins were allowed, designers could overlap blocks easier without having to create custom block styles.
This would also open up for more varied block patterns -the block pattern directory can not use custom block styles.
The text was updated successfully, but these errors were encountered: