I need these images to be centered in this slideshow, the background-color is black, so if it doesn't fill the entire width or height then the surrounding area is just black. I need the images to completely fit.
How can I scale these images to fit properly? This is my code so far:
<div id="logo">
<div id="slider-wrapper">
<div id="slider" class="nivoSlider">
<img src="images/mondepic1.jpg" alt="" />
<img src="images/img20.jpg" alt="" />
<img src="images/img22.jpg" alt="" />
</div>
</div>
<script type="text/javascript" src="lib/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="lib/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider();
});
</script>
</div>
</div>
#slider-wrapper {
background:black;
width: 978px;
height: 389px;
margin:0 auto;
}
#slider {
position:relative;
width: 978px;`enter code here`
height: 389px;
background:url(images/loading.gif) no-repeat 50% 50%;
}
#slider img {
position:relative;
top:0px;
left:0px;
display:none;
max-height:100%;
max-width:100%;
}
#slider a{
border:0;
display:block;
}
What if you set a CSS rule like this:
.nivoSlider img {
background-repeat: no-repeat;
background-size: cover;
}
This should size the image proportionally so you can see the whole thing, and so it fills its parent container.
What webkit meant in the comment was, that you should set the image property in CSS, like this:
.nivoSlider {
background-image: url(<path to image>);
}
Related
the background image of my web doesn't fill all the height of the window when there isn't enough content, here is a example:
Without content:
With content:
here is the app.component.html:
<body>
<!-- Background -->
<div class="bg">
<!-- nav -->
<app-navbar></app-navbar>
<!-- Logo -->
<div style="text-align:center">
<img width="200" alt="BookCloud Logo" [routerLink]="['/books']" src="../assets/logo3.png">
</div>
<!-- App -->
<div class="container">
<app-alert></app-alert>
<router-outlet></router-outlet>
</div>
</div>
</body>
and here is the app.component.css:
.container {
width:100%;
height:100%;
}
img {
outline: none;
}
html, body{
height: 100%;
}
.bg{
position: relative;
display:block;
background: url('../assets/bg.jpg') no-repeat center center fixed;
background-size: cover;
}
What im doing wrong? Thanks for reading.
You css should be
.bg{
position: relative;
display:block;
background: url('../assets/bg.jpg') no-repeat center center fixed;
background-size: 100% 100%;
}
If that doesn't work, change .bg to body.
I wont my image to be responsive like the rest of my website will be. How do i make it adjust to the size of the container. Not just the width but also resize the height?
The image is in a container with a max-width of 1300px, so i have made a test image that has the sizes 400px height and 1300px width
Here is the jsfiddle so you can have a look at what i mean.
http://jsfiddle.net/z6fj8dtg/2/
<div id="wrapper">
<div id="codeback">
</div>
<div id="container">
<div class="nav">
</div>
<div id="wrap">
<div class="banner">
<img src="http://s12.postimg.org/vnsghsvf1/banner.png" >
</div><!-- END OF BANNER -->
</div>
</div><!-- END OF CONTAINER -->
body{
background-color:#272822;
padding:0;
margin:0;
}
#wrapper{
width:100%;
height:inherit;
}
#codeback{
width:100%;
height:100%;
background-image:url('capture.jpg');
background-repeat: no-repeat;
position:fixed;
left:0px;
top:0px;
z-index:-1;
}
#container{
width:100%;
float:right;
}
.nav{
margin-top:200px;
width:80%;
max-width:1300px;
height:50px;
float:right;
background-color:black;
position:relative;
}
.fixedNav {
position:fixed;
margin:0;
width:80%;
right:0;
}
#wrap{
float:right;
width:80%;
max-width:1300px;
height:1500px;
background-color:white;
box-shadow: -1px -1px 35px lightblue;
}
.banner{
max-width:100%;
}
At the minute it just sits in the container but overflows to the right.
Yes that's no problem at all. Just insert the following CSS:
.banner img {
width: 100%;
height: auto; //Auto adjust height (maintain aspect ratio)
}
i used bootstrap image responsive class img-fluid and extra div tags to control image size.
<div style="width: 20%;height: 100px">
<img src="http://www.everlastingcelebrations.com/wp-content/uploads/2018/09/Top-Ganesh-Chaturthi-Messages-Images-Photos.jpg" class="img-fluid" alt="...">
</div>
I wonder how can I make a gradient background to repeat outside the defined layout.
http://i.imgur.com/CYk2FiE.png
Needed to repeat the water green and orange, which are also gradients.
Thank you.
<body>
<div id="header" style="width:1316px;height:80px;">
<div style="width:150px;height:72px;background-color:white;float:left;">repeat</div>
<div id="header-internal" style="background-color:gray;float:left;">
1016px
</div>
<div style="background-color:white;width:150px;height:72px;float:left;">repeat</div>
</div>
<div id="content">
what repeat background header left and right? two colors different?
</div>
<div id="footer">
footer
</div>
<br /> <br /> <br />
Should look like:
<img src="http://i.stack.imgur.com/KCbiK.png" />
</body>
and Css would be
body {
margin:0;
padding:0;
}
#header {
background:url("http://s10.postimg.org/jfhegkq49/bg_center.jpg") no-repeat;
background-position: bottom center;
background-color: #EFEFEF;
background-size:100%;
height: 80px;
}
#header-internal{
margin: 0 auto;
height: 72px;
width: 1015px;
}
#footer {
background-color: red;
height: 80px;
margin-top:20px;
}
I have a image gallery of the following structure :
<div class="gallery">
<div class="message">
Welcome to gallery
</div>
<img src="http://placehold.it/300x300" />
</div>
And the CSS :
.message {
position:absolute;
left:10px;
top:20px;
height:30px;
width:140px;
background:#333;
}
.gallery img {
opacity:.85;
}
But this causes the div message also transparent ! How to prevent it and whats the reason for transparency ?
DEMO
It seems the image is on top of the message div. I just swapped them over like this:
<img src="http://placehold.it/300x300" />
<div class="message">
Welcome to image gallery
</div>
And that fixed it for me.
fiddle
Another way is to give the message a z-index like this:
.message {
position:absolute;
left:150px;
top:20px;
height:30px;
width:140px;
background:#333;
z-index: 2;
}
.gallery img {
opacity:.85;
}
fiddle
You could give the image an id so only the image's opacity is lower
#img{ opacity: 85%; }
<img src="http://placehold.it/300x300" id="img" />
Or you could use a class
.img{ opacity: 85%; }
<img src="http://placehold.it/300x300" id="img" />
So then your could would be something like this:
<div class="gallery">
<div class="message">
Welcome to image gallery
</div>
<img src="http://placehold.it/300x300" class="img"/>
</div>
#img{ opacity: 85%; }
.img{ opacity: 85%; }
.message {
position:absolute;
left:10px;
top:20px;
height:30px;
width:140px;
background:#333;
}
Hope this helps you!
Demo
I have scoured relative questions on here and it seems like my situation is slightly unique.
I have a jQuery slideshow that I am wanting to make 100% width and height of browser with pure CSS.
I am able to get the width 100% and have it stretch with the page via my fluid layout, however when I try to make the height 100% it the image goes away completely.
It is forcing me to define the height with pixels.
I'm going to have a footer and header that stretch 100% width over the image / background with a wrapper inside each that is 960px wide.
Here is HTML structure:
<div class="page-section header clear">
<div class="wrapper clear">
<div class="logo clear">
</div>
</div>
</div>
<div class="page-section clear">
<!-- 100% width -->
<div id="revolver">
<div class="revolver-slide"><img src="<?php bloginfo('template_directory');?>/img/slides/slide-2.jpg"></div>
<div class="revolver-slide"><img src="<?php bloginfo('template_directory');?>/img/slides/slide-1.jpg"></div>
<div class="revolver-slide"><img src="<?php bloginfo('template_directory');?>/img/slides/slide-2.jpg"></div>
<div class="revolver-slide"><img src="<?php bloginfo('template_directory');?>/img/slides/slide-1.jpg"></div>
</div>
</div>
<div class="footer page-section clear">
<div class="wrapper">
<div class="footer_nav clear">
<div class="footer_nav_text">
SERIES
</div>
</div>
</div>
</div>
Here is the CSS:
body {
min-height:100%;
}
img. {
max-width:100%;
}
.page-section {
width:100%;
height:100%;
margin:0px auto 0px auto;
}
.wrapper {
width:960px;
margin:0px auto 0px auto;
padding:0px 20px 0px 20px;
}
/* header */
.header {
height:27px;
background-color:#fff;
position:absolute; top:20px;
z-index:100001;
}
#revolver {
background-color:#ccc;
max-width:100%;
max-height:100%;
z-index:10001;
}
.revolver-slide {
background-color:#fff;
max-width:100%;
max-height:100%;
background-position:center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.footer {
height:25px;
background-color:#fff;
z-index:1000001;
position:relative;
margin-bottom:15px;
border:1px #000 solid;
}
Is it something like this? I have put
html,body
{height:100%;
}
http://jsfiddle.net/p4z8q/14/