CSS HTML to replace glyphicon with img - html

I would like to replace the glyphicon with an img tag.
Currently the drop down is written as below
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-user"></span>
<strong>Desmond</strong>
<span class="glyphicon glyphicon-chevron-down"></span>
</a>
<ul class="dropdown-menu">
<li>
<div class="navbar-login">
<div class="row">
<div class="col-lg-4">
<p class="text-center">
<span class="glyphicon glyphicon-user icon-size"></span>
</p>
</div>
<div class="col-lg-8">
<p class="text-left"><strong>Desmond Soh</strong></p>
<p class="text-left small">Desmond#mail.com</p>
<p class="text-left">
Profile
</p>
</div>
</div>
</div>
</li>
<li class="divider navbar-login-session-bg"></li>
<li class="navbar-login-session-bg">
<div class="navbar-login navbar-login-session">
<div class="row">
<div class="col-lg-12">
<p>
Logout
</p>
</div>
</div>
</div>
</li>
</ul>
</li>
</ul>
How do i change the line of code to allow an img to fit nicely over the glyphicon? I believe I need a css to render it to a specific size as well. I have tried many ways but to no avail. Please help me thank you.

You need to replace the span tag with either a img or div tag:
Using an IMG tag and href to the preferred image
Using a DIV tag and CSS background property
Here's an example by replacing the span tag with .glyphicon class:
HTML
<div class="imgPlaceholder></div>
CSS
.imgPlaceholder{
background: url('http://i.stack.imgur.com/jGlzr.png') no-repeat 0 0 scroll;
background-color:#0C0C0C;
background-size: 100% 100%;
height:100px;
width:100px;
}

Related

how to put icons in line with other a tags?

i have just started learning web development and I have been facing a few issues related to the alignment of tags, buttons and icons.
Here are the issues I'm facing:
The brand name is not in line with the a tags. i tried display:inline; in every class but its not working.
the social media tags are hanging in mid air, I want them to be in line with the a tags. Again, i tried reducing the margin, padding and using the inline command but nothing seems to be working.
the bootstrap search button is also hanging mid air. I want all the above three to be in line.
Here's a screenshot of the page.
And here's the code
header {
background: #669999;
color: white;
padding: 5px 5px 5px 15px;
}
.fontsize {
color: white;
margin: 0px 0px 0px 10px;
font-size: 25px;
padding: 5px;
}
.icon {
float: right;
list-style-type: none;
margin: 0px 10px 0px 10px;
padding: 5px;
display: inline;
}
body {
margin: 0px;
}
.colors {
margin: 5px 10px 5px 10px;
padding: 10px;
color: white;
}
a:hover.colors {
color: black;
text-decoration: none;
}
.picturefont {
font-size: 25;
font-style: italic;
}
.whitespace {
padding: 10px;
margin: 50px;
}
#margin {
margin: 0px;
}
.frontpageimage {
width: 90%;
display: inline;
border: 1px solid black;
}
<h1 class="fontsize"> Brand name </h1>
<nav>
<a class="colors" href="home.html"> Home </a>
<a class="colors" href="contact.html"> Contact </a>
<a class="colors" href="recipe.html"> Recipes </a>
<a class="colors" href="order.html"> Order </a>
<ul>
<li class="icon">
<img src="icon-insta.png">
</li>
<li class="icon">
<img src="fb-icon.png">
</li>
<li class="icon">
<img src="phone-icon.png">
</li>
</ul>
</nav>
<form id="margin" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<!-- <li>Link</li> -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span
class="caret"></span></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</header>
<body>
<div class="row">
<div class="col-sm-2 whitespace picturefont">
<a href="recipe.html">
<img class="frontpageimage" src="oreo-cake.jpg"></a> Chocolate Cake</div>
<div class="col-sm-2 whitespace picturefont">
<a href="recipe.html">
<img class="frontpageimage" src="kitkat-cake.jpg"></a> Rasberry Sponge Cake
</div>
<div class="col-sm-2 whitespace picturefont">
<a href="recipe.html">
<img class="frontpageimage" src="green-cake.jpg"></a> Red Velvet Cake</div>
<div class="col-sm-2 whitespace picturefont">
<a href="recipe.html">
<img class="frontpageimage" src="KitKatCake3.jpg"></a> Mango Rose Tart
</div>
</div>
<div id="slider">
<div id="slider2">
<img id="choclatecake" src="oreo-cake.jpg" alt="Moist Chocolate Cake" />
<img id="choclatecake" src="kitkat-cake.jpg" alt="Moist Chocolate
Cake" />
<img id="choclatecake" src="green-cake.jpg" alt="Moist Chocolate Cake" />
<img id="choclatecake" src="KitKatCake3.jpg" alt="Moist Chocolate
Cake" />
</div>
</div>`
Forgive me for the improper format but I'm new here. Hoping to find some answers. Thanks
From my experience, the best way to organize the layout of a web page is to use tables (rows and columns). Start by sketching the layout and imagining boundaries around the items of your website.
I suggest that you use Bootstrap stylesheet by including the CSS file at your page header
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
Then using the CSS classes row and .col-md-* for div containter element classes.
Refer to the page (https://getbootstrap.com/docs/3.3/css/#grid-example-basic) for code examples.
Your structure might be something like the following:
<div class="row">
<div class="col-md-8">Brand name</div>
<div class="col-md-4">social media tags</div>
</div>
<div class="row">
<div class="col-md-6">navigation</div>
<div class="col-md-6">search</div>
</div>
<div class="row">
<div class="col-md-12">Body</div>
</div>
You need to put h1 tag inside nav tag.
You have closed the nav tag before starting form and you have another closing nav tag later.
Same reason as above.
Try it like this:
<nav>
<h1 class="fontsize"> Brand name </h1>
<a class="colors" href="home.html"> Home </a>
<a class="colors" href="contact.html"> Contact </a>
<a class="colors" href="recipe.html"> Recipes </a>
<a class="colors" href="order.html"> Order </a>
<ul>
<li class="icon">
<img src="icon-insta.png">
</li>
<li class="icon">
<img src="fb-icon.png">
</li>
<li class="icon">
<img src="phone-icon.png">
</li>
</ul>
<form id="margin" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span
class="caret"></span></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</nav>
#Student, you have a lot going on here, but most of your issues revolve around malformed HTML. So let's go through your issues one-by-one.
1) The brand name is not in line with the a tags. i tried
display:inline; in every class but its not working.
I'm only seeing your use of display:inline in a couple of your classes, but not on the brand name. Regardless, Bootstrap already has a brand with links built in for you. As you can see in the code below.
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle collapsed" aria-expanded="false" type="button" 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" href="#">Brand Name</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Home</li>
<li>Contact</li>
<li>Recipes</li>
<li>Orders</li>
</ul>
...
2) The social media tags are hanging in mid air, I want them to be in
line with the a tags. Again, i tried reducing the margin, padding and
using the inline command but nothing seems to be working.
To get these to go on the same line, you can nest the form and the social media icons in a div tag that pulls both of them to the right of the navigation bar using the navbar-right class. To make sure they're on the same line, use Bootstrap's float class: pull-left and pull-right. You'll need to add padding to the top of the a tags using padding-top CSS property. I've done it to one, so you can get an idea of how.
<div class="navbar-right">
<form class="navbar-form pull-left">
<div class="form-group">
<input class="form-control" type="text" placeholder="Search">
</div>
<button class="btn btn-default" type="submit">Submit</button>
</form>
<ul class="nav navbar-nav pull-right">
<li>
<img src="fb-icon.png">
</li>
<li>
<img src="phone-icon.png">
</li>
<li>
<img src="icon-insta.png">
</li>
</ul>
</div>
You'll just need to reapply some of your classes.

How to get rid of this excess scroll down bar

I'm just developing a Reproting Tool and due to some reason i have two scroll bars,one which is for Chrome or any other browser and the other is part of the HTML,i couldn't trace anything back to the HTML..
> </head>
<body style="min-height:20px">
<!-- START PAGE CONTAINER -->
<div class="page-container" style="min-height:20px">
<!-- START PAGE SIDEBAR -->
<div class="page-sidebar">
<!-- START X-NAVIGATION -->
<ul class="x-navigation">
<li class="xn-logo">
Reports
</li>
<li class="xn-profile">
<!--<a href="#" class="profile-mini">
<img src="assets/images/users/avatar.jpg" alt="John Doe" />
</a>-->
<div class="profile">
<!--<div class="profile-image">
<img src="assets/images/users/avatar.jpg" alt="John Doe" />
</div>-->
<!--<div class="profile-data">
<div class="profile-data-name">John Doe</div>
<div class="profile-data-title">Web Developer/Designer</div>
</div>-->
<!--<div class="profile-controls">
<span class="fa fa-info"></span>
<span class="fa fa-envelope"></span>
</div>-->
</div>
</li>
<li class="xn-title">Navigation</li>
<li >
<span class="fa fa-cogs fa-spin" title="Configure Reports"></span> <span class="xn-text">Configure Reports</span>
</li>
<li>
<span class="fa fa-cogs fa-spin" title="Configure Dashboard"></span> <span class="xn-text">Configure Dashboard</span>
</li>
<li class="active">
<span class="fa fa-eye" title="View Dashboard"></span> <span class="xn-text">View Dashboard</span>
</li>
</ul>
<!-- END X-NAVIGATION -->
Any Help would be deeply appreciated
what you can do is
to the main div you can apply css like for example you have
<div class ="main">
// rest of your code
</div>
in your main style.css you can put
.main {
width:100%;
height:90%;
overflow:hidden;
}
if this doesn't work you can use
body {
overflow-y:hidden;
}

bootstrap listgroup not centered

I created a listgroup, but it is not centering on the page. I am able to manipulate the text within each list group to align it left, but the whole element is appearing left on the page. Nothing has allowed me to center this on the page.
CSS:
.list-group{
width:40%;
text-align: center;}
HTML:
<div class="span12">
<ul class="list-group">
<li class="list-group-item">
<span class="badge">0</span>
<b>Stuff1:</b>
</li>
<li class="list-group-item">
<span class="badge">0</span>
<b>Stuff2: </b></li>
<li class="list-group-item">
<span class="badge">0</span>
<b>Stuff3:</b></li>
</ul>
</div>
If i correctly understand, you need to put in center of your page your <div>.
In bootstrap 3 is no css to do it :(
I use this class to <div> in center
.centerBlock {
float: none;
margin-left: auto;
margin-right: auto;
}
But if you want to align you text, you could use standart classes for it like text-center
Answer here.
Use Following:
display: block;
margin: 0 auto;
Use bootstrap grid classes as
<div class="row">
<div class="col-md-offset-4 col-md-4">
<ul class="list-group">
<li class="list-group-item">
<span class="badge">0</span>
<b>Stuff1:</b>
</li>
<li class="list-group-item">
<span class="badge">0</span>
<b>Stuff2: </b>
</li>
</ul>
</div>
</div>

Bootstrap CSS Alignment

I have been trying to get some alignment to work but I am having a hard time being successful. I'm not sure if there is already a CSS style in bootstrap for vertical alignment or not but that is what I am trying to accomplish.
I have a DIV (.well class) with an image and some text inside it. The Image aligns fine as its responsive so the height and placement is good. However, I am trying to align the button and Text vertically in the middle.
Here is a jsFiddle: http://jsfiddle.net/6z9skpeh/
<div class="col-md-6">
<div class="well wellFriends">
<div class="row">
<div class="col-md-4 friendPic">
<img src="http://oi62.tinypic.com/289j41s.jpg" class="img-responsive">
</div>
<div class="col-md-8 friendDetails">
<div class="row">
<div class="col-md-6"><strong>Bob Smith</strong>
<br><em>Department Name</em>
</div>
<div class="col-md-5 pull-right">
<!-- Single button -->
<div class="btn-group pull-right">
<button type="button" class="btn btn-primary dropdown-toggle pull-right" data-toggle="dropdown" aria-expanded="false">Friends <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
This is what I have so far:
This is what I am trying to do:
You can try like this: demo
css:
.v_align {
font-size: 0;
}
.v_align >[class*="col"] {
float: none;
font-size: 14px;
display: inline-block;
vertical-align: middle;
}
HTML:
<div class="row v_align">..</div>

Bootstrap navbar height changed on inserting brand image

I am new to HTML and CSS and have started coding in the last 4 days. I found bootstrap very useful to get things moving quickly.
Here is my attempt at getting a Navbar with transparency and fixed to the top.
http://jsfiddle.net/revanur/mf5wc/4/
<!-- Top-Navigation-Bar -->
<div class="row-fluid">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner" id="topbar">
<div class="container"> <img class = "brand" src="http://placehold.it/269x50" alt="SparkCharger" />
<button id="topbtn" type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
<div class="nav-collapse">
<ul class="nav pull-right">
<li class="active">
<form class="navbar-search brand">
<input type="text" class="search-query" placeholder="Search">
</form>
</li>
<li> <h5> Discover </h5>
</li>
<li> <h5> Blog </h5>
</li>
<li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"><h5>Start <span class="caret"></span></h5></a>
<ul class="dropdown-menu">
<li> <h6> Login </h6>
</li>
<li> <h6> Signup </h6>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- /Top-Navigation-Bar -->
However, the height of the navbar seems to change based on brand image size. I have no problem with that but I notice significant spacing between the image and the navbar top and bottom. How do I change this. Also, is it possible to fix the navbar size so that the navbar does not have a mind of its own.
There are a few things affecting the height of the navbar:
div class="navbar-inner" (5px padding)
img class="brand" (10px padding)
the size of the image
You can remove the padding by:
img.brand {
padding: 0;
}
And/Or you can specify the height of the navbar:
div.navbar-inner {
height: 10px;
}
Use something like this:
.brand {height: 25px;}
Demo: Fiddle