Background image not showing on .bg class element - html

I want to add a parallax scrolling effect to the .intro-body of my home-page in the same way that I have added this effect to the jumbotron images I have on my 'About', 'Resume' and 'Portfolio' pages. For some reason however the background image doesn't show when I apply it to the .bg class. The images show correctly on the other pages; the only difference is that I'm using #intro before .bg which I have done so that I can style this image to fit the entire height and width of the screen.
The background: CSS property is showing an image in the below fiddle, but I can't get it to work on my own website:
https://jsfiddle.net/c3do6hj0/
Is there something I'm doing wrong here? I've spent about 3 hours researching on SO but to no avail, so any ideas are much appreciated, thanks
My homepage
HTML
<header class="intro" id="intro">
<div class="bg"></div>
<div class="intro-body">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1 class="brand-heading">Jon Howlett</h1>
<p class="intro-text">Aspiring web designer<br/>&<br/>front-end developer</p>
<a href="#summary" class="btn btn-circle page-scroll">
<i class="fa fa-angle-double-down animate"> </i><span class="zero">Button Down</span>
</a>
</div>
</div>
</div>
</div>
</header>
CSS
#intro .bg {
background: url("https://upload.wikimedia.org/wikipedia/common/5/57/LA_Skyline_Mountains2.jpg") no-repeat scroll center bottom / cover;
background-size: cover!important;
position: fixed;
width: 100%;
height: 1000px;
top:0;
left:0;
z-index: -1;
}
.intro-body {
width: 100%;
height: auto;
padding: 100px 0px;
text-align: center;
color: #FFF;
background: transparent;
}

You have an inline style on the .bg div: height:0px;.
If i add the background: #000 url("images/intropage_mountains.jpg") no-repeat scroll center bottom / cover; to the .bg div then disable the inline style the background image shows up.
It appears that something in one of your javascript files is applying this inline-style.
When i change the class to something else such as bg_main the inline-style goes away and the background image works.
EDIT*: As a side note. I noticed that you have 2 different versions of jquery resourced.
http://code.jquery.com/jquery-2.1.4.min.js
and
http://www.jonhowlett.uk/js/jquery.js
I would advise you to only keep the latest version. having more than one jquery resource can sometimes cause conflicts with your code.

Related

Bootstrap - full screen header image followed by background image

New at Bootstrap. I'm having a problem setting my background image to follow the header image.
The header section has it's own full-screen background, which I then want to be followed by a tiled background image.
I tried:
<div class="header">...</div>
<div class="main-body">
<div class="container">...</div>
<div class="container">...</div>
...
</div>
<div class="footer">...</div>
with the following stylesheet:
.main-body {
text-align: center;
background: url(../img/setttings-bg-black.jpg) no-repeat center center;
background-size: 1024;
background-color: #000000;
}
.header {
text-align: center;
color: #000000;
background: url(../img/promo-bg.jpg) no-repeat center center;
background-size: cover;
}
The problem is that the main-body background's top is hidden by the bottom part of the header body.
What am I doing wrong?
Verify this link or link
have a solution for you.
problem 1)
What I did is I added a <img> below the first div (so the div with the class intro). The img has a clas of bg.
Than add this css:
.bg{
position:absolute;
z-index:-1;
width:100%;
height:100%;
}
here you have a working fiddle. I added a lot of <br> tags to show you it works.
You can also try to set the background image height:100% and width:auto;. If you do this the image won't be so crammed together on some screens.
problem 2)
I Gave every slide a class slide1. I also added to all the slide classes position:relative;. Taka a look at this fiddle.
i hope your question is now anwsered. If you have other problems, feel free to ask.

Full screen jumbotron with content underneath

I am using bootstrap frame work and using the jumbotron feature to create my header. I have a fixed navigation and want the jumbotron to be the full height and width of screen when scaled. I have content underneath the jumbotron that I want scrollable like regular. Just when someone gets to site its fullscreen jumbotron
html
<div class="jumbotron row">
<header>
<div class='navbar ........
... paragraph content ...
</div>
css
.jumbotron {
position: relative;
background: url('../img/pexels-photo.jpeg') no-repeat center center;
background-size: cover;
height:100%;
}
purii's answer is perfectly acceptable, however I'd opt for a slightly different approach when targeting the jumbotron BootStrap class:
HTML:
<div class="fullheight jumbotron row">
<header>
<div class='navbar ........
... paragraph content ...
</div>
CSS:
.fullheight.jumbotron {
position: relative;
background: url('../img/pexels-photo.jpeg') no-repeat center center;
background-size: cover;
min-height:100vh;
}
As you can see I placed a new fullheight class (can be any class name of course) within the "jumobtron" <div>. I then used that class name along with the jumbotron class as the selector for CSS styling.
The benefits of doing it this way is that it ensures that if you chose to use <div class="jumobtron"> on another page in the future, you can still use BootStrap's default styling for this class.
There are multiple ways to solve your problem. The most straight forward would be the usage of viewport units to scale your height. They are supported at least by IE >= 9.
.jumbotron {
position: relative;
background: url('../img/pexels-photo.jpeg') no-repeat center center;
background-size: cover;
min-height:100vh;
}

Bootstrap - 3 columns full responsive full height intro page

Currently I'm working on a website for a restaurant / hotel / vineyard. There are supposed to be 3 separate websites that I want to connect on one intro page.
I want to create an intro page which fills the full screen, 3 columns side by side, and each column with full height filled with a picture regarding to each site I want to link.
I started to go about it like this:
Bootstrap Columns:
<div class="row intro-div no-gutters">
<div class="col-md-4 fill-res"></div>
<div class="col-md-4 fill-wein"></div>
<div class="col-md-4 fill-hotel"></div>
</div>
CSS:
.fill-hotel{
height:100%;
min-height:100%;
background-image: url('../images/intro-hotel.jpg');
background-repeat: no-repeat;
background-position: top center;
background-color: #000000;
}
It looks great on my screen and when I change the size of my browser it's responsive, but it changes the section of the picture. For example, if there were a head in the picture, when I use a larger screen, then the head would be cropped on a small screen.
Any suggestions?
This is an optimized version of the CSS used by #Alvaro Menendez to avoid repeating properties for similar elements.
Note: there is also a slight change of background-position: top center; -> hopefully that should do it.
HTML
<div class="row intro-div no-gutters">
<div class="col-md-4 fill fill-res"></div>
<div class="col-md-4 fill fill-wein"></div>
<div class="col-md-4 fill fill-hotel"></div>
</div>
CSS
html, body, div {height:100%;}
.col-md-4 {
float:left;
width:33.333333333%;
background-size:cover;
}
.fill{
height:100%;
min-height:100%;
background-repeat: no-repeat;
background-position: top center;
background-color: #000000;
}
.fill-hotel{
background-image: url('http://upload.wikimedia.org/wikipedia/commons/2/28/Monarch_Butterfly_Danaus_plexippus_Vertical_Caterpillar_2000px.jpg');
}
.fill-res {
background-image: url('http://upload.wikimedia.org/wikipedia/commons/0/07/Soyuz_TMA-02M_spacecraft_in_a_vertical_position.jpg');
}
.fill-wein {
background-image: url('http://upload.wikimedia.org/wikipedia/commons/1/10/F-14A_VF-24_Vertical_Climb.JPEG');
}
Updated fiddle demo

How to make div background image inside another div to responsive?

I've been struggling with this issue for a while although tried from many topics in StackOverflow, and just wondered if anyone has any advice!
I'm using Bootstrap 3, basically I want to place images inside the container <div>, that will resize with the browser window, the content still staying inside it. So how can I make it responsive? Thank you in advance!
Demo
HTML
<div id="special-dishes-section">
<div class="container">
<div class="special-dishes">
</div> <!-- end special-dishes -->
</div> <!-- end container -->
</div> <!-- end special-dishes-section -->
CSS
#special-dishes-section{
background: url('../images/special-dishes-bg.jpg') no-repeat center center;
min-height: 560px;
padding: 71px 0 65px 0;
position: relative;
}
.special-dishes{
background: url('../images/wooden-bg.png') no-repeat center center;
min-height: 424px;
}
box-sizing: border-box;
This property help you when it needs to be responsive.
See this link for more information:
http://www.w3schools.com/cssref/css3_pr_box-sizing.asp
Hope it helps you.
Try background-size: cover; or background-size: contain;.

How to apply image on top of background-image?

Some pages contain page-header element/class.
.page-header class look like this:
.page-header {
background: url(/public/images/page-header.png) no-repeat;
width: 1000px;
height: 190px;
color: white;
font-size: 17px;
margin: 0;
}
For Example:
index.html
<div class="page-header">
<h1>Homepage</h1>
</div>
about.html
<div class="page-header">
<h1>About</h1>
</div>
I want to add small image on top of the page-header using css, each page will have different image. How to do this and should I use span with css ?
With CSS3, you can apply multiple backgrounds to elements. These are layered atop one another with the first background you provide on top and the last background listed in the back. Only the last background can include a background color.
https://developer.mozilla.org/en-US/docs/CSS/Using_CSS_multiple_backgrounds
Yes you can add a SPAN and give the image,
NOTE: if you give any image to the header as a background, it will not useful to SEO, I suggest same image keep in IMG tag and out of the screen to get some SEO help too.
Ex:
.page-header {
background: url(/public/images/page-header.png) no-repeat;
width: 1000px;
height: 190px;
color: white;
font-size: 17px;
margin: 0;
position:relative;
}
.out-of-screen {
position:absolute;
top:-2000em;
}
<div class="page-header">
<h1>Homepage</h1>
<img src="/public/images/page-header.png" alt="alt text" class="out-of-screen">
</div>
If your looking for a secondary background image to be overlaid on the previous background image. Then try this. I haven't tried it myself but it may be the answer.
.page-header:after{
background-image:url('/public/images/page-header2.png' no repeat;
}
You may need to position the :after to where you want it on the page but it maybe easier to stick with the simple image tag as Sameera has suggested if you want the image to be in a certain location within the element.
position:fixed;
left:0;
top:30%;
width:200px;
height:auto
<div class="page-header">
<h1>Homepage</h1>
<img src="path/to/image.jpg" alt="" style="position:absolute; left:50px; top: 50px;" />
</div>
there is a css property calles z-index.
The higher the value the most 'front' it will be.
The lower the more Back t will be
Négative value are okay.
.front{
z-index: 999;
}
.back{
z-index: 0;
}
NOTE: different-browser seems to have different behaviour.
To answer your question, Give a z-index lower to your header and add an elemt (span would be good) with an higher z-index
Use Multiple Backgrounds with CSS3.
Add padding-top to .page-header position page-header.png to bottom and
place second background at top.
http://css-tricks.com/stacking-order-of-multiple-backgrounds/
http://www.css3.info/preview/multiple-backgrounds/
CSS allows us to add multiple backgrounds images just by adding a comma (,) between them.
HTML
<div class="bg-image">
CSS
.bg-image{
outline: 2px solid black;
padding:20em;
background-image:
url(https://images.unsplash.com/photo-1634148739677-a5bb54df2611?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=774&q=80),
url(add another ".svg img" or any type of image);
background-repeat: no-repeat, repeat;
background-position:right 20% center 0px, top left;
background-size:auto, 10px;}