I'm creating a simple bootstrap template, but i facing a problem. My problem is my background image not showing.
.asheader{
background:url('asset/header_bg.png')no-repeat;
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
.asfooter{
background-image:url('asset/footer_bg.png');
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
i wonder why, because i have 2 html pages index.html and index2.html , in my index.html the background img is showsing up, but in index2.html the background is not showing up.
here is my index.html fullpage
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="asset/css/flexslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
#media (max-width: 766px){
img{
width:50%;
height:50%;
}
}
#media (min-width: 768px){
.navbar-nav{
float:none;
margin: 0 auto;
display: table;
table-layout: fixed;
}
}
.navbar.transparent.navbar-inverse .navbar-inner {
border-width: 0px;
-webkit-box-shadow: 0px 0px;
box-shadow: 0px 0px;
background-color: rgba(0,0,0,0.0);
background-image: -webkit-gradient(linear, 50.00% 0.00%, 50.00% 100.00%, color-stop( 0% , rgba(0,0,0,0.00)),color-stop( 100% , rgba(0,0,0,0.00)));
background-image: -webkit-linear-gradient(270deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
background-image: linear-gradient(180deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
}
#Intro {
display: inline-block;
}
#topnavbar {
top: 15px;
}
.carousel {
width:600px;
height:300px;
margin: 0 auto;
}
.lookbook{
width:600px;
height:auto;
margin: 0 auto;
}
.lookbook > h2{
text-align: center;
}
.ladiesroom{
width:600px;
height:300px;
margin: 0 auto;
}
.ladiesroom > h2{
text-align: center;
}
.afterlookbook{
width:630px;
height:300px;
margin: 0 auto;
}
.instagram{
width:630px;
height:auto;
margin: 0 auto;
border: 1px solid blue;
}
.instagram > h2{
text-align: center;
padding-bottom: 10px;
}
.carousel-inner > .item > img {
margin: 0 auto;
}
div.c-wrapper{
width: 100%;
margin: auto;
}
.navbar a {
color: black;
}
blockquote{
width:600px;
height:300px;
margin: 0 auto;
margin-top: 50px;
border: 2px 0px 2px 0px #000;
border: none;
}
blockquote:before {
color: #ccc;
content: open-quote;
font-size: 4em;
line-height: 0.1em;
margin-right: 0.25em;
vertical-align: -0.4em;
}
blockquote p {
display: inline;
}
.carousel-inner > .item > img,
.carousel-inner > .item > a > img{
width: 100%; /* use this, or not */
margin: auto;
}
.container-fluid
{
padding-top: 50px;
background-size:100% auto;
}
.top-buffer { margin-top:10px; }
.asheader{
background:url('asset/header_bg.png')no-repeat;
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
.asfooter{
background-image:url('asset/footer_bg.png');
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="asheader">
<div id="Intro" class="col-md-offset-5">
<img src="asset/logo_hitam.png" width="200px" height="50px">
</div>
<nav id="topnavbar" class="navbar transparent">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About Us</li>
<li>Product</li>
<li>Promo</li>
<li>Competition</li>
<li>Ladies Room</li>
<li>Need Help?</li>
</ul>
</div>
<!--- -->
</nav>
<div class="c-wrapper">
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<img src="https://dummyimage.com/600x300/000/fff">
</div>
<div class="item">
<img src="https://dummyimage.com/600x300/000/000">
</div>
<div class="item">
<img src="https://dummyimage.com/600x300/000/000">
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</div>
<div class="lookbook">
<h2>Lookbook</h2>
<div id="" class="flexslider slide_thumb">
<ul class="slides">
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
</ul>
</div>
</div>
<div class="afterlookbook">
<div class="col-lg-6 col-sm-2 col-sm-12">
<img src="asset/mini-banner.jpg" width="100%" height="100%">
</div>
<div class="col-lg-6 col-sm-12">
<img src="asset/mini-banner.jpg" width="100%" height="100%">
</div>
<br><br>
<div class="top-buffer col-lg-6 col-lg-push-6 col-sm-12">
<img src="asset/quiz_mini-banner.jpg" width="100%" height="100%"></div>
<div class="top-buffer col-lg-6 col-lg-pull-6 col-sm-12">
<img src="asset/mini-banner.jpg" width="100%" height="100%"></div>
</div>
</div>
<blockquote style="border-top:5px solid black; border-bottom: 5px solid black;" class="quotes">
<p>asdfasdfasdfasdf</p>
</blockquote>
<div class="asfooter">
<div class="ladiesroom">
<h2>Ladie's Room</h2>
<table class="table table-bordered">
<tr>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
</tr>
</table>
</div>
<div class="instagram">
<h2>See The Latest On Instagram</h2>
<table class="table table-bordered">
<tr>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
<td><img src="http://via.placeholder.com/100x100"></td>
</tr>
</table>
</div>
</div>
</div>
<script defer src="asset/js/jquery.flexslider.js"></script>
<script>
$(document).ready(function(){
$(window).resize(function() {
if ($(window).width() < 960) {
$('.navbar').removeClass('transparent');
$('.navbar').toggleClass('navbar-default');
}
else {
$('.navbar').toggleClass('transparent');
$('.navbar').removeClass('navbar-default');
}
})
})
$(document).ready(function() {
$('.slide_thumb').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 210,
itemMargin: 5,
asNavFor: '.slide_thumb',
itemWidth: 210,
itemMargin: 5,
minItems: 2,
maxItems: 4
});
});
</script>
</body>
</html>
and here is index2.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="asset/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" href="asset/css/flexslider.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
#media (min-width: 768px){
.navbar-nav{
float:none;
display: table;
table-layout: fixed;
}
}
.navbar.transparent.navbar-inverse .navbar-inner {
border-width: 0px;
-webkit-box-shadow: 0px 0px;
box-shadow: 0px 0px;
background-color: rgba(0,0,0,0.0);
background-image: -webkit-gradient(linear, 50.00% 0.00%, 50.00% 100.00%, color-stop( 0% , rgba(0,0,0,0.00)),color-stop( 100% , rgba(0,0,0,0.00)));
background-image: -webkit-linear-gradient(270deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
background-image: linear-gradient(180deg,rgba(0,0,0,0.00) 0%,rgba(0,0,0,0.00) 100%);
}
#topnavbar,#bottomnavbar{
top: 15px;
}
#bottomnavbar{
height:100px;
}
.carousel-inner > .item > img {
margin: 0 auto;
}
div.c-wrapper{
width: 100%;
margin: auto;
}
.navbar a {
color: black;
}
.center-block {
margin-right: auto;
margin-left: auto;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
}
.asheader{
background:url('asset/header_bg.png')no-repeat;
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
.asfooter{
background-image:url('asset/footer_bg.png');
background-repeat:norepeat;
background-position: center;
background-size: contain;
}
blockquote{
border: none;
border-bottom: 1px solid #ccc;
border-top:1px solid #ccc;
}
</style>
</head>
<body>
<div class="asheader">
<div id="Intro" class="col-md-offset-5 col-md-5">
<img src="asset/logo_hitam.png" width="200px" height="50px">
</div>
<nav id="topnavbar" class="navbar transparent col-md-offset-2 col-md-8">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About Us</li>
<li>Product</li>
<li>Promo</li>
<li>Competition</li>
<li>Ladies Room</li>
<li>Need Help?</li>
</ul>
</div>
<!--- -->
</nav>
<div class="c-wrapper">
<div id="myCarousel" style="background:black !important" class="carousel slide col-md-offset-3 col-md-6">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<img src="https://dummyimage.com/600x300/000/fff">
</div>
<div class="item">
<img src="https://dummyimage.com/600x300/000/000">
</div>
<div class="item">
<img src="https://dummyimage.com/600x300/000/000">
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</div>
<div class="lookbook col-md-offset-3 col-md-6 text-center">
<h2>Lookbook</h2>
<div id="" class="flexslider slide_thumb">
<ul class="slides">
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
</ul>
</div>
</div>
<div class="grid col-md-offset-3 col-md-6 text-center">
<table class="table">
<tr>
<td><img src="asset/mini-banner.jpg" width="100%" height="100%"></td>
<td> <img src="asset/mini-banner.jpg" width="100%" height="100%"></td>
</tr>
<tr>
<td>
<img src="asset/mini-banner.jpg" width="100%" height="100%">
</td>
<td> <img src="asset/mini-banner.jpg" width="100%" height="100%">
</td>
</tr>
</table>
</div>
<div class="quote col-md-offset-3 col-md-6 text-center">
<blockquote class="quote-card">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
<cite>
Lorem I psum
</cite>
</blockquote>
</div>
</div>
<div class="lookbook col-md-offset-3 col-md-6 text-center">
<h2>Ladies Room</h2>
<div id="" class="flexslider slide_thumb">
<ul class="slides">
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_cheesecake_brownie.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_lemon.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_donut.jpg" />
</li>
<li>
<img src="asset/images/kitchen_adventurer_caramel.jpg" />
</li>
</ul>
</div>
</div>
<div class="instagram col-md-offset-3 col-md-6 text-center">
<h2>See The Latest On Instagram</h2>
<table class="table table-bordered">
<tr>
<td><img src="http://via.placeholder.com/120x120"></td>
<td><img src="http://via.placeholder.com/120x120"></td>
<td><img src="http://via.placeholder.com/120x120"></td>
<td><img src="http://via.placeholder.com/120x120"></td>
<td><img src="http://via.placeholder.com/120x120"></td>
</tr>
</table>
</div>
<div class="instagram col-md-offset-3 col-md-6 text-center">
<h2>SUBSCRIBE TO OUR NEWSLETTER</h2>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.
Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</p>
<div class="input-group">
<input type="text" class="form-control"/>
<span class="input-group-addon">
<i class="fa fa-check"></i>
</span>
</div>
</div>
<nav id="bottomnavbar" class="navbar navbar-inverse col-md-12 fixed-bottom">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collection of nav links, forms, and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About Us</li>
<li>Product</li>
<li>Promo</li>
<li>Competition</li>
<li>Ladies Room</li>
<li>Need Help?</li>
</ul>
</div>
<!--- -->
</nav>
</div>
<script src="asset/js/jquery.flexslider.js"></script>
<script>
$(document).ready(function(){
$(window).resize(function() {
if ($(window).width() < 960) {
$('.navbar').removeClass('transparent');
$('.navbar').toggleClass('navbar-default');
}
else {
$('.navbar').toggleClass('transparent');
$('.navbar').removeClass('navbar-default');
}
})
})
$(document).ready(function() {
$('.slide_thumb').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 210,
itemMargin: 5,
asNavFor: '.slide_thumb',
itemWidth: 210,
itemMargin: 5,
minItems: 4,
maxItems: 4
});
});
</script>
</body>
</html>
any solution ? thanks in advance. Here is my folder structure
I do a test in index2. i add this in my css
body{
background:url('asset/header_bg.png')no-repeat;
}
the image is showing up. So, it's 100% not a path problem
I guess the fact that the <blockquote> element is missing in the second html document is causing the backgroud-image dimensions to be missing too (not set). Somehow the size of the background-image is depending on that element. Adding some dimensions to the quote class seems to fix it, i.e.:
.quotes {
height: 600px;
}
I hope it helps!
I am able to create a full-width image background in Bootstrap 3. An example can be shown here:
body,
html {
height: 100%;
}
body {
padding-top: 50px;
}
.full {
padding: 0 !important;
margin: 0 auto !important;
background-size: cover;
overflow: hidden;
}
.wide {
width: 100%;
height: auto;
}
.logo {
color: #fff;
font-weight: 800;
font-size: 14pt;
padding: 25px;
text-align: center;
}
.line {
padding-top: 20px;
white-space: no-wrap;
overflow: hidden;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Username
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="full" style="background-image:url('https://c.stocksy.com/a/RcN300/z0/805779.jpg');">
<div class="container">
<div class="row clearfix">
<div style="padding: 0 0 200px 0;">
<div class="col-xs-5 line">
<hr>
</div>
<div class="col-xs-2 logo text-center">Logo</div>
<div class="col-xs-5 line">
<hr>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="text-center">
<h1>Content</h1>
</div>
</div>
<!-- /.container -->
When the page displays for Desktop, the image is shown wide covering entire area.
When the page displays for mobile, all the image now shows as if a zoom-out occurred.
What's this behavior? How can I make the image in mobile view look similar to the image displayed in desktop version?
Is this related to responsive imaging?
Thanks
/Bilal
This is caused by the standard behavior of cover. If you resize your desktop browser to a portrait like size, you'll see what I mean.
One option would be to use a media query, so when page is viewed in portrait mode, it will look somewhat better.
body,
html {
height: 100%;
}
body {
padding-top: 50px;
}
.full {
padding: 0 !important;
margin: 0 auto !important;
background-size: cover;
overflow: hidden;
}
.wide {
width: 100%;
height: auto;
}
.logo {
color: #fff;
font-weight: 800;
font-size: 14pt;
padding: 25px;
text-align: center;
}
.line {
padding-top: 20px;
white-space: no-wrap;
overflow: hidden;
text-align: center;
}
#media (orientation: portrait) {
.full {
background-size: 200% auto;
background-position: top right;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Username
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="full" style="background-image:url('https://c.stocksy.com/a/RcN300/z0/805779.jpg');">
<div class="container">
<div class="row clearfix">
<div style="padding: 0 0 400px 0;">
<div class="col-xs-5 line">
<hr>
</div>
<div class="col-xs-2 logo text-center">Logo</div>
<div class="col-xs-5 line">
<hr>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="text-center">
<h1>Content</h1>
</div>
</div>
<!-- /.container -->
I have a problem in my css. I want to make my navbar like this ( as you can see, it has no background on navbar and it joins with slider ). I have tried every advice in youtube tutorials but nothing worked.
Here's the link I want to show you:
http://theme.ridianur.com/alamak/
I was able to change the color background of my navbar by opening bootstrap.min.css in notepad, search for "navbar-default", and change the color code. But, I wasn't able to make it no background like I want to.
My html :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="boot/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<title>Image Slider</title>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>HOME</li>
<li>NEWS</li>
<li>ABOUT</li>
<li>CONTACT US</li>
</ul>
<div class="logo">
<img src="kets.png">
</div>
</div>
</nav>
<div class="container-fluid hero-slide">
<div class="row">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="img/1.jpg" alt="Cats1">
<div class="carousel-caption">
<div class="tekslide1">
<h1>Hewan yang mainstream</h1>
<p>Kita juga gatau kenapa milih topik kucing</p>
</div>
</div>
</div>
<div class="item">
<img src="img/2.jpg" alt="Cats2">
</div>
<div class="item">
<img src="img/3.jpg" alt="Cats3">
</div>
<div class="item">
<img src="img/4.jpg" alt="Cats4">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</body>
</html>
and my css :
#charset "utf-8";
#font-face{
font-family: 'custom';
src: url('OpenSans-Regular.ttf') format('truetype'); //<-- semicolon
}
#font-face{
font-family: 'custom1';
src: url('Alternate.ttf') format('truetype'); //<-- semicolon
}
#media (min-width: 768px){
.navbar .navbar-nav{
display: inline-block;
float: none;
vertical-align: top;
font-family: 'custom';
letter-spacing: 5px;
padding-top: 12px;
margin-bottom: -20px;
}
.tekslide1{
font-size: 25px;
padding-left: 300px;
padding-bottom: 500px;
font-family: 'custom1';
}
.navbar .navbar-collapse{
text-align: right;
padding-right: 120px;
}
.navbar-default .navbar-collapse .nav >li >a {
color: #EEEEEE;
margin-left: 10px;
margin-right: 5px;
font-size: 13px;
}
.navbar-default .navbar-collapse .nav >li >a:hover, .navbar-default .navbar-collapse .nav >li >a:focus{
color: #BDBDBD;
background: none;
}
.logo{
float: left;
padding: 2px;
margin: 2px;
margin-bottom: -15px;
margin-left: 5%;
border: none;
border-radius: 100px;
}
.hero-slide{
margin-top: -20px;
}
.navbar li { color: #000 }
Any help would be appreciated. Thanks!
I'll explain this in pseudocode. If you want help you need include relevant bits of html and css in your post, not the archive of an entire site.
This effect you're looking for is nothing more than:
<div class="wrapper">
<div class="navigation">
</div>
<div class="banner">
</div>
</div>
and
.wrapper{background:url('your_image.jpg');}
.navigation, .banner{background:transparent;}
A graphic applied to a parent container and navigation / banner with transparent backgrounds.
I'd like to show an image, full height image, like this website on every browsers without writing specific number of pixels like height: 400px;.
mobile
laptop
How should I change my css? Would you please let me know?
html {
font-size: 62.5% !important; /* 10 px */
}
/*header {
position: absolute;
text-align: center;
top: 0px;
z-index: 1000;
color: #fff;
width: 100%;
height: 64px;
border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}*/
/*img {
display: block;
max-width: 100%;
height: auto;
}*/
.carousel-control.left, .carousel-control.right {
background: none !important;
filter: progid: none !important;
outline: 0;
}
.carousel .carousel-control {
visibility: hidden;
}
.carousel:hover .carousel-control {
visibility: visible;
}
.carousel-indicators {
bottom:-50px;
}
.carousel-inner {
margin-bottom:50px;
}
/*.logo {
float: left;
text-align: left;
display: inline-block;
}*/
.transparent-header {
z-index: 22;
position: absolute;
width: 100%;
left: 0;
background-color: rgba(255, 255, 255, 0.9);
border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
#carousel-example-generic {
width: 100%;
height: 100%;
position: relative;
}
.nav::after,
.nav::before,
.navbar-header::after,
.navbar::after {
display: table-caption;
}
.nav.navbar-nav li,
.nav.navbar-nav li a {
display: inline-block;
}
#gnav {
font-size: 0.9em;
width: 100% !important;
}
#gnav
/*#gnav_nav*/ {
text-align: center;
}
#logo
img {
display: block;
margin: auto;
}
#intro {
position: relative;
overflow: hidden;
}
#bg-image3 {
background: url("http://htmlcoder.me/preview/the_project/v.1.3/template/images/slider-fullscreen-slide-1.jpg");
}
.bg-image {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
display: block;
overflow: hidden;
position: relative;
width: 100%;
height: 100%;
}
<!DOCTYPE html>
<html lang="en-EN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- for IE -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>{% block title %}{% endblock %}</title>
<meta name=”robots” content=”noindex,nofollow,noarchive,noodp,noydir”>
<!-- <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css"> -->
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="{% static 'font-awesome/css/font-awesome.min.css' %}" />
{% block additional_css %}{% endblock %}
{% block custom_css %}{% endblock %}
</head>
<body>
<div id="wrapper">
<!-- <div class="container" id="range">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" style="background-color:Yellow;">ExtraSmall</div>
<div class="hidden-xs col-sm-6 col-md-4 col-lg-3" style="background-color:green;">Small</div>
<div class="hidden-xs hidden-sm col-md-4 col-lg-3" style="background-color:blue;">Midium</div>
<div class="hidden-xs hidden-sm hidden-md col-lg-3" style="background-color:Red;">Large</div>
</div>
</div> -->
<!-- Header -->
<header id="header" class="header clearfix fixed transparent-header" >
<div class="container-fluid" id="header-inner">
<div class="row">
<!-- Global Navigation -->
<div id="gnav" class="" data-spy="affix" data-offset-top="94">
<nav class="navbar navbar-inverse" id="gnav_nav">
<ul class="nav navbar-nav" id="gnav_ul">
<li class="dropdown">
<a class="" data-toggle="dropdown" href="index.html">商品紹介</a>
<!-- Dropdown -->
<ul class="dropdown-menu">
<li>
<a class="" href='#'>ジュース <i class=""></i></a>
<ul class="sub-dropdown">
<li>オレンジ</li>
<li>アップル</li>
<li>グレープ</li>
</ul>
</li>
<li>
<a class="" href='#'>寿司 <i class=""></i></a>
<ul class="sub-dropdown">
<li>マグロ</li>
<li>サーモン</li>
<li>エンガワ</li>
</ul>
</li>
</ul> <!-- dropdown-menu -->
</li> <!-- .dropdown -->
<li class="dropdown">
<a class="" data-toggle="dropdown" href="index.html">ご注文</a>
<ul class="dropdown-menu">
<li>
<a class="" href='#'>スマートフォン <i class=""></i></a>
<ul class="sub-dropdown">
<li>iPhone</li>
<li>Xperia</li>
<li>Galaxy</li>
</ul>
</li>
<li>
<a class="" href='#'>野菜 <i class=""></i></a>
<ul class="sub-dropdown">
<li>トマト</li>
<li>レタス</li>
<li>枝豆</li>
</ul>
</li>
</ul> <!-- dropdown-menu -->
</li> <!-- .dropdown -->
<li class="dropdown">
<a class="" data-toggle="dropdown" href="index.html">お問い合わせ</a>
<ul class="dropdown-menu">
<li><a class="" href='#'>自分用</a></li>
<li><a class="" href='#'>他人用</a></li>
</ul> <!-- dropdown-menu -->
</li> <!-- .dropdown -->
<li class="dropdown">
<a class="" data-toggle="dropdown" href="index.html">会社案内</a>
<ul class="dropdown-menu">
<li><a class="" href='#'>フォーム</a></li>
<li><a class="" href='#'>電話</a></li>
</ul> <!-- dropdown-menu -->
</li> <!-- dropdown -->
</ul> <!-- .nav .navbar-nav -->
</nav> <!-- .navbar .navbar-default -->
</div> <!-- #gnav .col-md-9 -->
<!-- Logo -->
<div id="logo" class="">
<a href="#">
<img src="http://vignette2.wikia.nocookie.net/logopedia/images/e/ee/Burger_King_Logo.svg.png/revision/20120422044236" id="logo-img" class="img-responsive logo-img" height="50" width="50">
</a>
</div> <!-- #logo .col-sm-3 -->
</div> <!-- .row -->
</div> <!-- .container -->
</header> <!-- #header .clearfix -->
<section id="intro">
<article id="apple">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="melon img-responsive" src="http://htmlcoder.me/preview/the_project/v.1.3/template/images/slider-fullscreen-slide-1.jpg" alt="First slide">
</div>
<div class="item">
<img class="melon img-responsive" src="http://htmlcoder.me/preview/the_project/v.1.3/template/images/slider-fullscreen-slide-2.jpg" alt="Second slide">
</div>
<div class="item" id="bg-image3">
<div class="bg-image" id="bg-image3">
<h2 class="" id="">This is the headline</h2>
<p class="" id="">This is a pen. This is an apple. U~n, apple pen.</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div>
<span>Bootstrap carousel</span>
</div>
</article>
</section>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
<h1><span>I LOVE TOMATO!!!!</span></h1><br>
</div> <!-- #wrapper -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>
Bootstrap: 3.3.4, HTML5, jQuery: 2.1.3
Set your image as background-image for that element with background-size: cover;
Set that element to height: 100vh;
Quick example: https://jsbin.com/dajepaw/1/
*{box-sizing:border-box;margin:0;}
html, body{height:100%;font:14px/1.4 sans-serif;}
header {
position: fixed;
z-index: 1;
width: 100%;
top: 0;
height: 72px;
background: #fff;
}
article {
background: #fff;
height: 50vh;
} article:nth-child(odd) {
background: #f7f7f7;
}
footer {
background: #444;
height: 72px;
}
/* SPECIAL CLASSES */
.fullWithBackground {
height: 100vh;
background: url(https://i.stack.imgur.com/LCupt.png) 50% fixed;
background-size: cover;
color: #fff;
}
.centerInner{
display: flex;
align-items: center;
justify-content: center;
}
<header>Header</header>
<div class="fullWithBackground centerInner">
<div>GALLERY</div>
</div>
<main>
<article>Article 1</article>
<article>Article 2</article>
</main>
<footer>Footer</footer>
I have the following CSS code, and my problem is that my
nav bar comes on top of my header block. How can I move
the nav bar straight down from the header?
header {
background: black;
height: 60px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
}
header img {
float: left;
margin-right: 10px;
position: relative;
}
header h1 {
color: white;
font: 26px Helvetica, Arial, sans-serif;
line-height: 60px;
margin: 0;
vertical-align: middle;
}
nav {
background: black;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
}
give the nav a margin-top that is the same height of your navbar.
nav {
background: black;
margin: 0;
margin-top:60px;
padding: 0;
position: absolute;
width: 100%;
}
#H.A; you give position absolute to your header block & nav block . So, when you give position absolute to an element then the element remove for the normal flow
CSS:
nav {
top:60px;
padding: 0;
position: absolute;
width: 100%;
}
Read this article for more http://css-tricks.com/791-absolute-positioning-inside-relative-positioning/
<!DOCTYPE html>
<html >
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style>
.navbar-fixed-top{
position:static;
}
</style>
</head>
<body>
<div class="row">
<div class="col-lg-12">
<div class="intro-message">
<h1>HOST</h1>
<h3>two is better than one</h3>
<hr class="intro-divider">
<ul class="list-inline intro-social-buttons">
<li>
<i class="fa fa-twitter fa-fw"></i> <span class="network-name">Twitter</span>
</li>
<li>
<i class="fa fa-github fa-fw"></i> <span class="network-name">Github</span>
</li>
<li>
<i class="fa fa-linkedin fa-fw"></i> <span class="network-name">Linkedin</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
<div class="container topnav">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand topnav" href="/">Host</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
Login
</li>
<li>
Sign up
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
</body>
</html>