Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

html - Safari image height in CSS grid

I have issues in mobile safari, where an image is exceeding the grid height. Chrome is working fine... Here how it looks like in Chrome:

enter image description here

And how it looks like on my iPhone:

enter image description here

Following is my code (simplified):

          <div
        style={{
          gridTemplateColumns: '25% 55% 20%',
          display: 'grid',
          minHeight: '20vh'
        }}
      >
          <img
            src={this.props.parent.sliderPhotos[0]}
            style={{
              objectFit: 'cover',
              width: '100%',
              height: '100%'
            }}
          />

        <div
          style={{
            backgroundColor: 'yellow',
          }}
        ></div>
        <div
          style={{
            backgroundColor: 'red',
          }}
        ></div>
      </div>

Styling with height 100% and max-height did not work. Also flex-direction: "column" and padding-top: "100%" are not working.

Any more ideas how it will work in both browsers?

question from:https://stackoverflow.com/questions/65846644/safari-image-height-in-css-grid

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

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...