Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS column-count and position relative behavior in Chrome

Tags:

html

css

If I use a position relative for an item which is inside column-count, it does not appear in Chrome (latest version).

In the following code, .left has the position: relative and it does not appear.

How can I make it work without removing the relative position property?

HTML:

<div class="container">                
    <div class="box">Lorem ipsum dolor sit amet</div>

    <div class="box">
        <div class="item">
            <div class="left"><img src="http://i.imgur.com/E4rkDHN.jpg" /></div>
            <div class="right">luctus et ultrices posuere cubilia Curae</div>
        </div>
    </div>
<div>

CSS:

.container {
    width: 500px;
    overflow: hidden;
    -moz-column-count: 2;
    -moz-column-gap: 20px;
    -webkit-column-count: 2;
    -webkit-column-gap: 20px;
    column-count: 2;
    column-gap: 20px;
}

.box {
    width: 240px;
    overflow: hidden; 
    break-inside: avoid-column;
    -webkit-column-break-inside: avoid;
    -o-column-break-inside: avoid;
    -ms-column-break-inside: avoid;
    column-break-inside: avoid;
    -webkit-backface-visibility: hidden;
    margin-bottom: 20px;
    background: yellow;    
}

.left {
    position: relative;
}

Demo: http://jsfiddle.net/eLmhedrt/

like image 976
sam Avatar asked Dec 10 '25 20:12

sam


1 Answers

Just add the position: relative; to img, like this:

img{
  position: relative;
}

You can also check it on jsfiddle. I hope it helps you :)

like image 108
Mario Kurzweil Avatar answered Dec 13 '25 09:12

Mario Kurzweil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!