make all images the same size in a slideshow - html

im trying to make all the images in a slideshow be of same size, I've tried using
.slideshow-container img {
height: 100%;
width: 100%;
}
but doesn't work

I would first start out with adding this to your css
body,html{
height: 100%;
}
Then I would create a parent element to basically contain all of the images
<div class='container'> <!-- your images --> </div>
Then just set the width of that to say 500px by 500px
Finally, you should be able to use height & width at 100%
$(document).ready(function(){
$('.2').click(function(){
$('.img1').css("display","none");
$('.img2').css("display","block");
});
$('.3').click(function(){
$('.img2').css("display","none");
$('.img3').css("display","block");
});
});
// not a very good example of how to make a slideshow but its more to show how to make images the same size as opposed to having a working slideshow
body,html{
margin: 0;
height: 100%;
}
.container{
width: 80%;
height: 50%;
background-color: black;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 5%;
}
.img1{
background-image: url('https://images.pexels.com/photos/284951/pexels-photo-284951.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
}
.img2{
background-image: url('https://images.pexels.com/photos/397998/pexels-photo-397998.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
display: none;
}
.img3{
background-image: url('https://images.pexels.com/photos/376533/pexels-photo-376533.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="container">
<div class="img1"></div>
<div class="img2"></div>
<div class="img3"></div>
</div>
<button class="1">Img 1</button>
<button class="2">Img 2</button>
<button class="3">Img 3</button>
<!--
Photo by Timotej Nagy from Pexels https://www.pexels.com/photo/dark-gold-lamp-light-284951/
-->

If you want a full screen slider, it's going to be something more complicated than that. Try this:
.slideshow-container {
position:absolute;
height:100%;
width:100%;
}
.slideshow-container img {
max-width:100%;
width:100%;
position:fixed;
left:0;
}
I would also recommend to check examples. From here maybe:
Link

Related

How to fit multiple background images to any screen

i´m building a website that has different background images as you scroll down.
The problem I am facing is that each background image is not fitting the screen (in terms of the height). My images won't fit the whole screen unless I set them to have 1100px and therefore will not be fitting the 100% of my height, but let's say they will be going down, on those 20% who are going to come as I scroll down.
I would like to have my images fit 100% of the screens height, without being cut
and going bellow the page.
.container {
background-size: 100%;
background-size: cover;
margin-top: 1vh;
}
.parallax {
background: url("quem-somos.png") ;
background-size: cover;
width: 100%;
height: 100%;
}
.parallax2{
background: url("servicos.png") no-repeat center;
background-size: cover;
height: 1100px;
width: 100%;
background-attachment: scroll;
}
.parallax3{
background: url("depoimentos.png") no-repeat center;
background-size: cover;
height: 1100px;
width: 100%;
background-attachment: scroll;
}
.parallax4{
background: url("comecando.png") no-repeat center;
background-size: cover;
height: 1100px;
width: 100%;
background-attachment: scroll;
}
.parallax5{
background: url("sac.png") no-repeat center;
background-size: cover;
height: 1000px;
background-attachment: scroll;;
width: 100%;
}
.parallax6{
background: url("onde-atuamos.png") no-repeat center;
background-size: cover;
background-attachment: scroll;
height: 1000px;
width: 100%;
}
I have put all of the images inside the container
<div class="container">
<div class="parallax" id="about">
</div>
<div class="parallax6" id="operations">
</div>
<div class="parallax2" id="servicos">
</div>
<div class="parallax3" id="Depoimentos">
</div>
<div class="parallax4" id="Comecando">
</div>
<div class="parallax5" id="sac">
</div>
</div>
You can use this to set the div height to the screen height, you have to make sure html and body have a min height of the screen and also set the background-size: cover
Also .image1 .image2 in my case are direct children of the body element in my example
html, body {
margin: 0;
width: 100%;
min-height: 100vh;
}
.image1 {
width: 100%;
height: 100vh;
background-color: red;
}
.image2 {
width: 100%;
height: 100vh;
background-color: blue;
}
You can have the child divs do the heavy lifting by setting heights to 100vh - the margin on top of the container.
https://jsfiddle.net/x2h0mat7/
Here's a working example with the original html:
<div class="container">
<div class="parallax" id="about">
</div>
<div class="parallax6" id="operations">
</div>
<div class="parallax2" id="servicos">
</div>
<div class="parallax3" id="Depoimentos">
</div>
<div class="parallax4" id="Comecando">
</div>
<div class="parallax5" id="sac">
</div>
</div>
and the css:
.container {
margin-top: 1vh;
}
.container>div {
min-height: calc(100vh - 1vh);
height: 100%;
width: 100%;
background-size: cover;
background-repeat: no-repeat;
z-index: 2;
display: flex;
overflow: hidden;
background-attachment: scroll;
}
.parallax {
background: url("https://via.placeholder.com/1600x1200/0000FF/");
}
.parallax2 {
background: url("https://via.placeholder.com/1600x1200/990000/") no-repeat center;
}
.parallax3 {
background: url("https://via.placeholder.com/1600x1200/ffee66/") no-repeat center;
}
.parallax4 {
background: url("https://via.placeholder.com/1600x1200/66eeff/") no-repeat center;
}
.parallax5 {
background: url("https://via.placeholder.com/1600x1200/ee66ff/") no-repeat center;
}
.parallax6 {
background: url("https://via.placeholder.com/1600x1200/ffee66/");
}

How to adjust the image without affecting the background image in HTML and CSS

I am trying to adjust my logo at the center of the webpage, but whenever I adjust it in my CSS file, the background is getting affected by the changes so there will be white spaces on top.
.bgimage {
width: 1903px;
height: 1000px;
background-image: url(https://drive.google.com/uc?id=1ZtitWTmH3qglyS7uv4X32GDQv35fmhwG);
background-attachment: fixed;
background-size: cover;
margin-top: 60px;
display: block;
}
.bgimage .ETLOGO {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 80px;
width: 40%;
height: 50%
}
<div class="bgimage">
<img src="https://drive.google.com/uc?id=1vXkFqCQzC7sagYCBOuAwDQMf-uhJTmAo" class="ETLOGO">
</div>
Here is a photo of my website.
I think what you wanted was padding at the top of the logo, instead of margin. Try this:
.bgimage {
background-attachment: fixed;
background-image: url(https://upload.wikimedia.org/wikipedia/commons/0/0f/MOS6581_chtaube061229.jpg);
background-position: center;
background-size: cover;
height: calc(100vh - 50px);
width: 100vw;
}
.bgimage .ETLOGO {
display: block;
height: 50%;
margin: 0 auto;
padding-top: 40px;
}
<div class="bgimage">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Intel-logo.svg/440px-Intel-logo.svg.png" class="ETLOGO">
</div>

CSS full height of dynamically inserted img element

I am using a plugin that allows me to create sliders. The images I upload are dynamically inserted as <img> tags into the front page layout. While I know how to render an image in its full height using CSS, I am unable to get this to work with the html image element.
This code works great if the image is served by CSS and the result is perfect.
HTML
.container{
width: 750px;
height: 600px;
background: rgba(222,211,210,1);
border: solid 4px #8c8c8c;
}
.slider{
background-image: url('https://i.imgur.com/Ye4Uugc.jpg');
width: 100%;
height: 100%;
background-size: auto 100%;
background-position: center;
background-repeat: no-repeat;
}
<div class="container">
<div class="slider">
</div>
</div>
But the problem I have is when the image is inside HTML like this. I cannot meddle with the HTML code as the plugin inserts the image tags dynamically and I have more than 500 images inserted by the plugin.
HTML
.container{
width: 750px;
height: 600px;
background: rgba(222,211,210,1);
border: solid 4px #8c8c8c;
}
.slider{
width: 100%;
height: 100%;
background-size: auto 100%;
background-position: center;
background-repeat: no-repeat;
}
<div class="container">
<div class="slider">
<img src="https://i.imgur.com/Ye4Uugc.jpg">
</div>
</div>
The result for the above code is this. Obviously overflow: hidden; clips the lower part exceeding the container height, which is not the solution I want as I need the image to fit inside the container retaining its original ratio.
Any help is appreciated.
add rules to images also to prevent overflow:
.container{
width: 750px;
height: 600px;
background: rgba(222,211,210,1);
border: solid 4px #8c8c8c;
}
.slider{
width: 100%;
height: 100%;
background-size: auto 100%;
background-position: center;
background-repeat: no-repeat;
}
.slider img{
max-width:100%;
max-height:100%;
height:auto;
}
<div class="container">
<div class="slider">
<img src="https://i.imgur.com/Ye4Uugc.jpg">
</div>
</div>
I'm remake code from #Ali Sheikhpour. adding width: 100%; to .slider img
.container{
width: 750px;
height: 600px;
background: rgba(222,211,210,1);
border: solid 4px #8c8c8c;
}
.slider{
width: 100%;
height: 100%;
background-size: auto 100%;
background-position: center;
background-repeat: no-repeat;
}
.slider img{
max-width:100%;
max-height:100%;
height:auto;
width: 100%;
}
<div class="container">
<div class="slider">
<img src="https://i.imgur.com/Ye4Uugc.jpg">
</div>
</div>

Invisibility of the one element go through the other(white) as well to Background image

this is my code:
body{
background: url(https://static.pexels.com/photos/29628/pexels-photo.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.header{
height:2em;
width:100%;
position:fixed;
top:0; left:0;
background-color:white;
}
.main{
width:100%;height:10em;
margin-top:5em;
background-color:white;
}
.mainPanel{
width:50%;
margin:auto;
background-color:yellow;
height:5em;
}
<html>
<body>
<div class="header">
</div>
<div class="main">
<div class="mainPanel">
</div>
</div>
</body>
</html>
I want that the yellow div is transparent and shows the background image of body. That the yellow div go trough the white div behind it and shows the background image of body. Is that possible? I hope it comes clear what i meant.
The only workaround I can think of would involve breaking your white box into three rectangles and arranging them to form a window of sorts. Here, try this out:
body {
background: url(https://static.pexels.com/photos/29628/pexels-photo.jpg) no-repeat center center fixed;
background-size: cover;
}
.header {height:2em;width:100%;position:fixed;top:0; left:0;}
.main {
width: 100%;
height: 10em;
margin-top: 5em;
}
.mainPanel{
width:50%;
margin:auto;
height:5em;
}
<html>
<body>
<div id="left-rectangle" style="background-color: white; width: 25%;height: 160px; position: absolute;"></div>
<div class="right-rectangle" style="background-color: white; width: 25%; float: right; height: 160px;"></div>
<div class="center-rectangle" style="position: absolute;margin-left: 25%;background-color: white;width: 50%;height: 80px;margin-top: 80px;"></div>
<div class="header">
</div>
<div class="main">
</div>
</body>
</html>
You could simply repeat the background, and since it has a fixed position, it will be exactly like the body background and you will not notice a difference.
body, .mainPanel {
background: url(https://static.pexels.com/photos/29628/pexels-photo.jpg) no-repeat center center fixed;
background-size: cover;
}
Simply extend the background of body to .mainPanel to create the illusion.
Demo: jsFiddle
html, body {padding: 0; margin: 0;}
body, .mainPanel {
background: url(https://static.pexels.com/photos/29628/pexels-photo.jpg) no-repeat center center fixed;
background-size: cover;
}
.header {
height: 2em;
width: 100%;
position: fixed;
top: 0; left: 0;
background-color: #EEE;
}
.main {
width: 100%;
height: 10em;
margin-top: 5em;
background-color: white;
}
.mainPanel {
width: 50%;
margin: auto;
height: 5em;
border:1px dashed #CCC; /* just for demo */
}
<div class="header">header</div>
<div class="main">
<div class="mainPanel">
</div>
</div>

how to perfect a jumbotron image in my page

The image I selected is too big and does not fit the page vertically or horizontally. here is what I have:
<style>
.jumbotron {
height: 500px;
width: 100%;
}
.jumbo-container {
background-image: url('../img/challenge2.jpg');
background-repeat: no-repeat;
background-size: cover;
width: 100%;
}
</style>
<body>
<div class="jumbotron">
<div class="jumbo-container">
</div>
</div>
</body>
link to the picture I want: http://fc09.deviantart.net/fs71/f/2010/347/0/2/life_challenges_by_eddieretelj-d34scch.jpg
If I understand correctly you might need to use this take a look at my fiddle background-size: 100% auto; http://jsfiddle.net/mhussa19/r0pq2zra/2/
.jumbotron {
height: 500px;
width: 100%;
}
.jumbo-container {
background-image: url(' http://fc09.deviantart.net/fs71/f/2010/347/0/2/life_challenges_by_eddieretelj-d34scch.jpg');
background-repeat: no-repeat;
background-size: 100% auto;
width: 100%;
height:100%;
}
background-image: url('../img/challenge2.jpg'); height:100%; width:100%;
should work