Similar to selecting img[title="test"]
can I somehow select images that have a style property of float
set to left
?
I want to set left and bottom margins for them which don't apply to right floating images.
Thank you.
The elements after the floating element will flow around it. The elements before the floating element will not be affected. If the image floated to the right, the texts flow around it, to the left and if the image floated to the left, the text flows around it, to the right.
The float CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it. The element is removed from the normal flow of the page, though still remaining a part of the flow (in contrast to absolute positioning).
left : floats the element to the left of its container. right : floats the element to the right of its container. inherit : the element inherits the float direction of its parent.
Peter W solution needs to be fixed like this: (changed ~=
to *=
)
img[style*="float:left"] {
margin: 5px 15px 0px 0px;
}
img[style*="float:right"] {
margin: 5px 0px 0px 15px;
}
The only issue is that it makes an exact match, so float:right
will match, while float: right
wont (notice the extra space).
I tested successfully in Chrome and IE9, but in IE emulation mode will not work ...
Just to expand on this a bit, this is what I've been using for all of my images. It catches floats as well as images that are aligned.
img[align="left"],
img[style*="float: left"],
img[style*="float:left"]{
margin: 5px 15px 0px 0px;
}
img[align="right"],
img[style*="float: right"],
img[style*="float:right"]{
margin: 5px 0px 0px 15px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With