I am noticing an interesting problem with my site. I have a section that has a static background image and as you scroll there's a quote and button (eventually will link to a store) over the top of it. To my knowledge, it was working in the past, but yesterday I noticed after a few seconds the background image is gone, replaced with just a gray background. The image will flicker in and out a bit before permanently being replaced with the gray background.
Here is my HTML:
<section class="bar background-image-fixed-2 no-mb color-white text-center">
<div class="dark-mask"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="icon icon-lg"><i class="fa fa-leaf"></i>
</div>
<h3><em>"Herb is the healing of a nation" - Bob Marley</em></h3>
<p class="text-center">
Get Some
</p>
</div>
</div>
</div>
</section>
Here is my CSS:
.bar.background-image-fixed-2 {
background-image: url('../img/fixed-background-2.jpg');
background-position: center center;
background-repeat no-repeat;
background-attachment: fixed;
background-size: cover;
}
The image URL is correct because it initially loads for a couple of seconds. Originally, this was written short hand but some suggestions I've seen recommended doing the long form for the CSS. I split it out, but that doesn't seem to make a difference.
Actual look (incorrect):
Expected look (which I get for a few seconds before it changes automatically):
Edit:
Here is a fiddle (though it's missing some javascript so it'll look funny).
please check your url is not proper loading :
.bar.background-image-fixed-2 {
background-image: url('https://images.unsplash.com/photo-1490810277975-e64342ceecf0?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=88e69bf894f334456f8ae269752556e1&auto=format&fit=crop&w=1650&q=80');
background-position: center center;
background-repeat:no-repeat;
background-attachment: fixed;
background-size: cover;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<section class="bar background-image-fixed-2 no-mb color-white text-center">
<div class="dark-mask"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="icon icon-lg"><i class="fa fa-leaf"></i>
</div>
<h3 class="text-white"><em>"Herb is the healing of a nation" - Bob Marley</em></h3>
<p class="text-center">
Get Some
</p>
</div>
</div>
</div>
</section>
Related
I have a simple code for a simple webpage, but it does not work: for some reason, the background is not displayed. I checked everything in different browsers on different computers. Where do you think there might be a mistake?
.section--map {
padding: 40px 0;
background: #e6e6e6 url("../images/map-bg.jpg") center no-repeat;
-webkit-background-size: cover;
background-size: cover;
}
<section class="section section--map">
<div class="container">
<div class="map">
<div class="map__title">
<div><i class="fas fa-map-marker-alt"></i></div>
<h2>Open Map</h2>
</div>
</div>
</div>
</section>
Did you check if path to your image is correct or it might be that your image type is .jpeg?
From a website theme, I have the following which cuts off the top of my video. I want to be able to re-size the video, even if it means not stretching across the full screen -
<section class="home-section bg-dark-30" id="home" data-background="assets/images/section-5.jpg">
<div class="video-player" data-property="{videoURL:'https://www.youtube.com/watch?v=MY_VIDEO_URL', containment:'.home-section', startAt:2, mute:true, autoPlay:true, loop:true, opacity:1, showControls:false, showYTLogo:false, vol:0}"></div>
<div class="video-controls-box">
<div class="container">
<div class="video-controls"><a class="fa fa-volume-up" id="video-volume" href="#"> </a><a class="fa fa-pause" id="video-play" href="#"> </a></div>
</div>
</div>
<div class="titan-caption">
<div class="caption-content">
<div class="font-alt mb-30 titan-title-size-1">Hello & welcome</div>
<div class="font-alt mb-40 titan-title-size-4">asdf</div><a class="section-scroll btn btn-border-w btn-round" href="#about">Learn More</a>
</div>
</div>
</section>
Here is the CSS of home-section:
.home-section {
position: relative;
background-color: #FFF;
background-repeat: no-repeat;
background-position: center center;
width: 100%;
z-index: 0;
background-size: cover;
}
How can I do this?
Link to template html page that I'm modifying:
http://markup.themewagon.com/titan/index_mp_classic_video_background.html
The area on my browser measures to be 1900 x 800 pixels. My video is 1280 x 720. So the proportions don't work out properly, and video gets cut off. Thus I Want to resize.
Hope that makes sense, thankful for any help. Any questions or anything not clear let me know.
You can try changing to background-size: contain;, so it scales the video so it fills the screen size
I am making a small eastern project. The website is here: My Website.
I need to make some boxes that contain a png picture on top of the background-picture like this:
I set the picture on the col, but I guess I need to make it as a background in CSS, since I cannot build something on top of an img tag:
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<center><img src="https://mimsi.dk/images/logo.jpg" class="img-fluid" alt="Eastern"></center>
</div>
</div>
<div class="row">
<div class="col-md-12">
<img src="https://mimsi.dk/images/eeg.jpg" alt="Eastern game" class="background">
</div>
</div class="row">
<div class="col-md-12" style="border: 1px solid red;">
<h1 style="text-align: center;">FOOTER</h1>
</div>
</div>
</div>
Instead of using the img src tag, I set this in my HTML and CSS:
<div class="col-md-12 bg">
.bg {
background-image: url("https://mimsi.dk/images/eeg.jpg");
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
But nothing has worked out yet. How can I set the background-image, so it is not going to the header logo or footer, so I can build my 8 boxes on top?
First there is a mistake in your HTML in this line </div class="row"> i think you got that you can't put class in closing div
Solution
I created a fiddle
Hi I have searched in previous questions and tried multiple ways but I still have trouble setting up opacity of my background image without effecting opacity of font.
this is my html:
<main>
<div class="background">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="center">
<h1>My name</h1>
<h3>this is my website</h3>
<hr>
<button id = "mainButton" type="button" class="btn btn-default btn-lg">Get Started!</button>
</div>
</div>
</div>
</div>
</div>
</main>
and this is css:
.background{
background-image: url("xxx.jpg");
width: 100%;
height:100%;
position:fixed;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
opacity:0.5;
}
*I tried to use rgba(0,0,0,0.5);
*I tried to set up another css rule just for h1, or the div with the text but still the same.
Please can anyone help?
Make the markup like this:
<main>
<div class="background">
</div>
<div class="container">
</div>
</main>
Give to main position: relative;
Give to background div position: absolute;
Fix the rest. You're done.
About background size
You can modify the image background size by background-size and using values like cover, contain, 100%, 100% 100% etc.
If you want to cover all the page, use value 100vh, meaning 100% of the viewport height.
I'm new to coding and figured best way to learn is to get a gig, which I did. I've got some basic (like very basic) HTML & CSS knowledge, but bootstraps layout seemed to fit for what I'm trying to accomplish. Please keep in mind this is my very first project ever(!) when it comes to coding.
So here's the design I'm trying to replicate:
montere.it
I'm interested just in the main page, the actual tiles below the main image to be exact. I can't seem to find the best solution to position 2 tiles with background image, side by side(no gaps), with some h1 text and a small <p> above the background image in the tile, positioned centrally. There will be two more tiles below the initial two.
I SPENT A WEEK looking for similar solutions, but I'm exhausted and confused over all information digested. Can some one just point me in the right direction as to which features to use?
It seems even if I get to position both images, there are always gaps (right or left), there's no way to position the text exactly above the image centrally so it stays in one place when the display is resized and I don't want to cry about the rest.
I have a feeling it's a dumb question to ask, since none of the info I've found provide an exact solution to this question, so probably must be really easy to do and I just can't seem to grasp it.
I do apologize for taking up your time, but I just have no one else to ask.
Cheers!
Please check this out:
<div class="row">
<div class="col-sm-6 col-xs 12 col-img" style="background-color: red">
<h1>Image 1</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: orange">
<h1>Image 2</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: green">
<h1>Image 3</h1>
</div>
<div class="col-sm-6 col-xs 12 col-img" style="background-color: yellow">
<h1>Image 4</h1>
</div>
</div>
And add this to your CSS file:
.col-img h1 {
margin-bottom: 0;
margin-top: 0;
text-align: center;
}
In case any one else runs into this problem, here's the fully working solution. I'm just not sure if it will disappear under gjfonte's link, so I want to be safe here:
Here's what was provided by #gjfonte:
<div class="row">
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-1">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-2">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-3">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
<div class="col-sm-6 col-xs 12 col-img">
<div class="bg-img img-4">
<div class="content">
<h1>Image 1</h1>
</div>
</div>
</div>
</div>
.content {
padding-top: 90px;
color: #fff
}
.content h1 {
margin-bottom: 0;
margin-top: 0;
text-align: center;
}
.col-img .bg-img {
text-align: center;
margin: 0 -15px;
background-position: center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 250px;
}
.bg-img.img-1 {
background-image: url("http://www.montere.it/assets/img/bg-qualitycycle-wrapper.jpg");
}
.bg-img.img-2 {
background-image: url("http://www.montere.it/assets/img/bg-qualitymap-wrapper.jpg");
}
.bg-img.img-3 {
background-image: url("http://www.montere.it/assets/img/bg-recipes-wrapper.jpg");
}
.bg-img.img-4 {
background-image: url("http://www.montere.it/assets/img/bg-journal-wrapper.jpg");
}