'How to fix image position in mobile view?
Solution 1:[1]
Learn about responsive layout and media query in CSS, here tutorial :
Add in head section
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Solution 2:[2]
It always depends what behavior you wish. But a good practice is to use media-queries. Then set min-widthor min-height` etc. Take a look in the working example below:
.w {
display:flex;
background: gray;
}
.w h1 {
font-size: 40px;
padding: 20px;
}
img {
width: 100%;
height: auto;
min-width: 200px;
}
}
@media only screen and (max-width: 600px) {
.w {
background-color: lightblue;
}
.w h1 {
font-size: 20;
font-weight: bold;
padding: 5px;
}
}
<div class="w">
<div>
<h1>Lorem Ipsum</h1>
</div>
<div>
<img src="https://via.placeholder.com/500">
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nay Lin Aung |
| Solution 2 | Maik Lowrey |
