Home > Mobile >  How to use if else condition in sccs on float property?
How to use if else condition in sccs on float property?

Time:01-07

I would to apply margin on image that use float property like this:

<img style="float:left;" ...>

as HTML, and this is the scss:

    $flottant: left;
     @if $flottant == left {
     img {
     // Cas de l'image en float left
     margin: 0 em(10px) 0 0;
     }
     } @else {
     margin: 0;
     }

But I don't know how to target the float propertie of the image... If someone know about it.

Thanks

I try to evaluate the float property for image.

EDIT: I don't know how to include this code into a if/else condition, but I think it's a starting point to make difference between images with float and no float.

 img[style*="float: left"] {
 // Cas de l'image en float left
margin: 0 em(10px) 0 0;
}
         img{margin: 0;}

CodePudding user response:

I don't think I clearly understand the question, but here is how I would trigger float property to apply the margin :

img {
  float: left;
  margin: 0 10px 0 0;
}

img[style*="float: right"] {
  float: right;
  margin: 0;
}

Hope it helps

  • Related