I have problem setting the background image from folder, 'img/flower.jpg'. I tried using the following code in CSS, the image does not show up: However it works if I reference it from a source in internet.
#navigation,.navbar .navbar-default{
background-image: url("img/flower.jpg");
background: url('img/flower.jpg');
}
<div class="container">
<!-- Navigation -->
<nav class="navbar navbar-default " id="navigation" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
Jeen's Portfolio
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
</div>
/* CSS used here will be applied after bootstrap.css */
#navigation,.navbar .navbar-default{
border-top: 2px dotted blue;
border-bottom: 2px dotted blue;
background-image: url("http://upload.wikimedia.org/wikipedia/commons/6/6b/Bubble_3.jpg");
background: url('http://upload.wikimedia.org/wikipedia/commons/6/6b/Bubble_3.jpg');
font-style: zapfino;
}
Demo
We just need to add a div tag with the class as a container and put the navbar-brand(image or logo) inside this div. After that, we just need to add the class mx-auto to the navbar-brand class.
Just add . bg-img class on your <img> element and .has-bg-img class to parent element that you want to apply a background image. Images are part of the DOM and are transformed into CSS background-image after they are fully loaded.
Use any of the . bg-color classes to add a background color to the navbar.
This can better if you can show your folder structure for the images and the style file or if possible give the url.your img folder should be in same directory in which your style file exists .then this will work .
#navigation,.navbar .navbar-default{
background-image: url("img/flower.jpg");
}
or if it is in some other directory find the path with the use of ../
. this denote that you are one step back from the directory .
like this
#navigation,.navbar .navbar-default{
background-image: url("../img/flower.jpg"); /* assuming img folder is one step back from css*/
}
background-image: url('/img/flower.jpg');
background-image: url('http://upload.wikimedia.org/wikipedia/commons/6/6b/Bubble_3.jpg');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With