If a div has “clear:right”, nothing should float to the right of it, should it?

前端 未结 5 1865
暗喜
暗喜 2021-02-15 11:04

I seem to have gotten confused as to what the css \"clear\" keyword means.

I have a number of div elements, all with \"float:left\". The second last div element also has

5条回答
  •  梦如初夏
    2021-02-15 11:55

    ahruss's answer is the correct one, but I also noticed no one really answered your question. Basically clear:left refers to left floating elements. clear:right refers to right floating elements.

    Since your element is floating left, not right, clear:right won't affect it.

    The other thing you could do is wrap the two text elements in a separate div from the blue box, float that container div in and the blue div, then when you float the two text elements, your clear:left code will put the date under the text still within your container div and not under the blue image to it's left.

    Like this:

    0
    ShopTVC Wallace and Gromit WOA 6Apr11
    00:00:32

    and add this to your css:

    div.TextContainer {
       float:left;
    }
    

    Add in whatever other visual styles you need.

提交回复
热议问题