Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

html - Flexbox bug on safari

I'm having an issue with some divs in Safari, other browsers work fine. Sometimes, but not every time, these rectangles appear, distort the layout, and overlap the images. It doesn't occur on my local server, just when I deploy it.

Take note of the background color appearing over the images

It fixes itself if:

  1. I resize/zoom the page.
  2. I open web inspector (just open it, not anything else)
  3. I refresh the page—sometimes

This is what I have for the three divs (.ldb-part) and their parent div (.ldb):

HTML:

        <div class="ldb">
        <div class="ldb-part">
            <h3>Landscape</h3>
            <img src="/Image1.jpg" alt="">
            <p>Lorem ipsum dolor sit amet, consectetur...</p>
        </div>
        <div class="ldb-part">
            <h3>Design</h3>
            <img src="/Image2.jpg" alt="">
            <p>Lorem ipsum dolor sit amet, consectetur...</p>
        </div>
        <div class="ldb-part">
            <h3>Build</h3>
            <img src="/Image3.jpg" alt="">
            <p>Lorem ipsum dolor sit amet, consectetur...</p>
        </div>
        </div>

CSS:

.ldb {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;

    -webkit-align-items: center;
    -moz-align-items: center;
    -ms-align-items: center;
    align-items: center;

    justify-content: center;

    position: absolute;
    top: 93%;
    max-width: 70vw;
    height: 20em;
    padding-bottom: 4em;
}

.ldb-part {
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;

    -webkit-align-items: center;
    -moz-align-items: center;
    -ms-align-items: center;
    align-items: center;

    justify-content: space-around;

    flex-direction: column;

    text-align: center;

    width: 30%;
    height: inherit;
    margin: 0 1em;
    padding: .5em;
    border: 1px solid #BDBDBD;
    border-radius: 10px;
    background: #FFFDF8;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In my experience flexbox does not work in Safari at all, but it worked when I substituted it with gird display.

Using grid display may solve the problem here to

.ldb-part {
display: grid;
grid-template-rows: auto auto;

align-items: center;
justify-content: space-around;

text-align: center;

width: 30%;
height: inherit;
margin: 0 1em;
padding: .5em;
border: 1px solid #BDBDBD;
border-radius: 10px;
background: #FFFDF8;

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...