The image may not have a good aspect ratio because you have a fixed width and a fixed height
.banner img {
width: 100%;
}
...
@media screen and (min-width: 800px) {
.item1 {
height: 500px;
}
}
You set a to the item1 image. This means that this image has already an class="img-responsive" so in responsive design it is better to give the item1 image a width likeheight:auto
.banner img {
width: 100%;
}
...
@media screen and (min-width: 768px) {
.item1 {
width: 420px; /* example, or use a % */
}
}
Try to use the correct @media Bootstrap breakpoints, in Bootstrap 3:
min-width: 768px / min-width: 992px / min-width: 1200px
You changed the css of class in position: absolute with fixed left and right. This will give problems because .containeer is not defined this way in Bootstrap..container
update
Example how to use the Bootstrap classes with your image and text.
<div class="container">
<div class="row banner">
<div class="col-sm-12 item1">
<img src="https://i.ibb.co/h9pxMmg/home-slider-1.jpg" class="img-responsive" alt="">
</div>
<div class="col-sm-12 home_slider_content">
<div class="home_slider_title">
A new Online Shop experience.
</div>
<div class="home_slider_subtitle">
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nullam a ultricies metus.
Sed nec molestie eros. Sed viverra
velit venenatis fermentum luctus.
</div>
<div class="home_button">
<a href="#" class="btn btn-success">Shop Now</a>
</div>
</div>
</div>
</div>
with css
.banner .item1 img {
width: 100%;
margin: 0 auto;
}
@media (min-width: 576px) {
.banner .item1 img { width: 400px; }
}
@media (min-width: 768px) {
.banner .item1 img { width: 650px; }
}
@media (min-width: 992px) {
.banner .item1 img { width: 900px; }
}
.home_slider_content {
margin-top: 22px;
text-align: center;
}
.home_slider_title {
font-size: 60px;
font-weight: 600;
background-color: #933;
color: #fff;
line-height: 1.2;
}
.home_slider_subtitle {
margin-top: 22px;
font-size: 14px;
font-weight: 400;
background-color: #c66;
color: #fff;
line-height: 2.14;
}
.home_button {
margin-top: 40px;
}
You have to apply
width: 100vw;
height: 100vh;
object-fit: contain;
To directly , you can use imgid or class directly but last method is not recommended as it will apply to all img tags in the documentimg
I have used red to show how much area image covers but as background so image ratio's are maintainedobject-fit: contain;
object-fitUse
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
To remove any unnecessary scroll bars as tags have some default horizontal and margin . So , here used the padding tagbody
.Image {
width: 100vw;
height: 100vh;
object-fit: contain;/*Can be cover , fill , none...*/
background-color: red;
}
body {
box-sizing: border-box;
margin: 0;
padding: 0;
}
<div>
<img src="https://www.hdnicewallpapers.com/Walls/Big/Rainbow/Rainbow_on_Mountain_HD_Image.jpg" class="Image" />
</div>
When I remove the following CSS rule from all background images:
"background-attachment: fixed;"
The images then scale down when viewed on iPhone.
I can think of only one solution without JS and it is BAD one. You could load all images and using CSS media queries show only one. your site will be huge and slow but if you cant use JS this is the only option i can think of.
PHP get_browser(http://php.net/manual/en/function.get-browser.php) could be used to do some kind of raw estimation on client window size. But that would be an estimation.
The solution I suggest is to output al images in HTML data attribute and using JS determine the correct size then replace previously empty src with corect src
image element example:
<img src=""
data-full-src=" full-link "
data-large-src=" large-link "
data-medium-src=" medium-link "
data-small-src=" small-link " />
JS function example:
var image = getElementById( your-img-ID ); //or some other selector
var selectedSrc = "data-full-src";
image.setAttribute('src', image.getAttribute(selectedSrc) );