How to fix a background img that isn't showing - html

My background image isn't showing and I can't figure out why. I've already read through a few other threads but none of the suggestions are working.
The path to the background image is correct, that's not the problem. I've added a height and size/position etc.
.images {
position: relative;
height: 100%;
width: 100%;
}
#slideshow {
display: block;
position: absolute;
background: url("links/slideshow/_anx_tote2.jpg");
background-size: contain;
background-repeat: no-repeat;
background-position: 100% bottom;
height: 100%;
z-index: -1;
}
<div class="images">
<div id="slideshow"></div>
</div>
The background image should cover the right half of the screen.

* {
margin: 0;
padding: 0;
}
body,
html {
height: 100%;
}
.images {
position: relative;
height: 100%;
width: 100%;
}
#slideshow {
display: block;
position: absolute;
width: 100%;
background-image: url("https://picsum.photos/200");
background-size: cover;
background-repeat: no-repeat;
background-position: 100% bottom;
height: 100%;
z-index: -1;
}
<div class="images">
<div id="slideshow"></div>
</div>
You need to add 100% height for body and HTML.

The image doesn't show because there was no width and height set to #slideshow.
Adding percentage height to a div, a height has to be determined first.
For more information, you can see here.
Thus I have added height: 100vh; and width: 100% to #slideshow;
.images {
position: relative;
height: 100%;
width: 100%;
}
#slideshow {
display: block;
position: absolute;
background: url("https://i.imgur.com/WLimwqR.png");
background-size: contain;
background-repeat: no-repeat;
background-position: 100% bottom;
height: 100vh;
width: 100%;
z-index: -1;
}
<div class="images">
<div id="slideshow"></div>
</div>

#slideshow {
background: url(links/slideshow/_anx_tote2.jpg) no-repeat transparent;
background-size: cover;
height: 100%;
}

Related

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>

Resize a banner in CSS

I will wish to get a result like this for example in CSS.
Here is my result for now
How to do to have the same result that the first image?
Here is below my code.
.banner02{
height: 100px;
width: 100%;
position: absolute;
margin: 0px;
}
And my HTLM
<div class="my_banner_reg">
<img class="banner02" src="images/slider.jpg"/>
</div>
Thanks
I don't know what you are written, But add the following styles to your element that have background-image:
header{
width: 100%;
height: 100px;
background-image: url(http://trak.in/wp-content/uploads/2018/01/10-Rupees-Coins.jpg);
background-size: cover;
background-position: center;
}
<header></header>
And another way:
div {
width: 100%;
height: 100px;
overflow: hidden;
}
div > img {
width: 100%;
height: 100%;
object-fit: cover;
}
<div>
<img src="http://trak.in/wp-content/uploads/2018/01/10-Rupees-Coins.jpg" />
</div>

Why isn't my background img covering the entire page?

I want my background image to cove the entire div but instead there are a lot of white space
HTML
<div class="backgroundsecction">
<div class="backgroundimg"></div>
</div>
CSS
.backgroundimg{
background-image: url(https://i.imgur.com/MAdBtV4.png);
height: 100%;
width: 100%;
background-repeat: no-repeat;
position: relative;
}
.backgroundsecction{
height: 900px;
width: 100%;
}
Please use background-size:cover
.backgroundimg{
background-image: url(https://i.imgur.com/MAdBtV4.png);
height: 100%;
width: 100%;
background-repeat: no-repeat;
position: relative;
background-size:cover;
}
.backgroundsecction{
height: 900px;
width: 100%;
}
<div class="backgroundsecction">
<div class="backgroundimg"></div>
</div>
If the white border bothers you around the background, use something like this:
.backgroundimg {
background-image: url(https://i.imgur.com/MAdBtV4.png);
height: 100%;
width: 100%;
background-repeat: no-repeat;
position: relative;
}
.backgroundsecction {
height: 900px;
width: 100%;
}
body {
margin: 0;
}
<div class="backgroundsecction">
<div class="backgroundimg"></div>
</div>
If the image is smaller than the screen, than use larger image. it is generally good practice to prepare that some people could have very very large resolution displays...
Or scale it up, like #ankitapatel mentioned: with background-size:cover;.
Use 2 things as suggested
body {
margin : 0px; //add this
}
.backgroundimg {
background-image: url(https://i.imgur.com/MAdBtV4.png);
height: 100%;
width: 100%;
background-repeat: no-repeat;
position: fixed; //change fixed to cover entire
}
.backgroundsecction{
height: 900px;
width: 100%;
}
<div class="backgroundsecction">
<div class="backgroundimg"></div>
</div>

How to put text on top of a pattern overlay CSS

Might be an easy one can't get this to work. I've succeded in overlay a background image with a pattern but now the header is placed behind the pattern as well. I've tried to use z-index (as depicted in my code below) but it still not working. Any ideas?
Result
Index.html
<div class="content">
<div class="subheader">
<div class="container">
<h1>PROVIDE <br>CREATIVITY IN <br> YOUR BUSINESS</h1>
</div>
<div class="pixel-overlay"></div>
</div>
</div>
Style.css
.content .subheader {
width: 100%;
height: auto;
display: inline-block;
padding: 130px 0 0;
background: url(../images/landing.jpg) no-repeat 50% 0%;
position: relative;
background-attachment: fixed;
text-align: center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-ms-behavior: url(../js/backgroundsize.htc);
}
.content .subheader:after {
content: "";
background: url(../images/pattern/pattern.png) repeat;
background-size: 90%;
background-attachment: fixed;
opacity: 0.2;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: 0;
}
.content .subheader h1 {
margin-top: 25%;
z-index: 100;
}
Try add position: relative; to the headline, like this:
.content .subheader h1 {
margin-top: 25%;
z-index: 100;
position: relative;
}
Your .content .subheader h1 have no position specified. Therefore, z-index will be useless.
Try adding position: relative:
.content .subheader h1 {
position: relative;
margin-top: 25%;
z-index: 100;
}

full screen background html

I'm trying to show a picture as the background of my website so I'm using the following code
HTML:
<div>
<img src="images/background.jpg" id="bg" alt="background_image" />
</div>
Css:
#bg {
width: 100%;
height: 75%;
position: absolute;
z-index: -5000;
}
I was wondering how can I put a limit on how big is the background going to get because I don't want it to stretch more than 2000px.
Thanks
Just include max-width in your CSS.
#bg {
width: 100%;
max-width: 2000px;
height: 75%;
position: absolute;
z-index: -5000;
}
I would use the following css:
html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
and remove your div entirely.
To limit the size you can:
#bg {
min-height: 100%;
max-width: 2000px;
width: 100%;
height: auto;
position: fixed;
top: 0;
bottom: 0;
}
You can use max-width
#bg {
width: 100%;
height: 75%;
position: absolute;
z-index: -5000;
max-width: 2000px; /* use this to limit the maximum width */
}
I haven't tested it, but add max-width:2000px; to your #bg selector.
try this
#bg {
width: 100%;
height: 100%%;
background-size:100%;
}