Overriding Bootstrap dropdown style - css

I'm trying to extend this custom component example http://getbootstrap.com/examples/cover/ by adding appropriate style to dropdown element.
<li class="dropdown masthead-dropdown">
<a class="" data-toggle="dropdown" href="#">Media<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Videos</li>
<li>Pictures</li>
</ul>
</li>
CSS:
.masthead-dropdown{
background-color: transparent !important;
border-color:white !important;}
Custom styles are included after bootstrap.css, but they doesn't work.

Going by the Cover menu list, I used it to guess the part of your code since I don't know what is wrapping the <li>:
<div class="masthead clearfix">
<div class="inner">
<h3 class="masthead-brand">Cover</h3>
<nav>
<ul class="nav masthead-nav">
<li class="active">Home</li>
<li>Features</li>
<li><ul class="dropdown">
<button class="dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Media
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>Videos</li>
<li>Pictures</li>
</ul>
</ul></li>
</ul>
</nav>
</div>
</div>
Then add to your CSS:
.dropdown-toggle {
background-color: transparent;
border-color: #fff;
border-style: solid;
border-top: none;
border-right: none;
border-left: none;
}
And you can change the dropdown background colors with this:
.dropdown-menu{
background-color: #000;
}
And the links font color:
.dropdown-menu>li>a{
color: #fff;
}
JSFiddle

Related

Left dropdown border not showing on page when I hover over button

Below is my code for the footer of a webpage I'm building:
<div class='footer'>
<footer class="page-footer font-small pt-4">
<div class="container text-center text-md-left">
<div class="row">
<ul class="list-unstyled">
<li>
Hello
</li>
<li>
Hello
</li>
<li class="dropdown">
<a class="footer-dropdown footerstyle dropdown-toggle" id="dropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Team
</a>
<div class="dropdown-menu sub-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="">Team members</a>
<a class="dropdown-item" href="">Our Story</a>
<a class="dropdown-item" href="">Join the team</a>
</div>
</li>
<li>
Hello
</li>
<li>
Hello
</li>
</ul>
</div>
</div>
</footer>
Below is the styling I've applied:
.dropdown-item {
font-family: Roboto-Regular;
background-color: #F0F0F7;
}
.dropdown-item:hover {
font-family: Roboto-Regular;
font-weight: bold;
background-color: #F0F0F7;
display: block;
cursor: pointer;
}
.dropdown:hover .dropdown-menu {
display: block;
font-family: Roboto-Regular;
background-color: #F0F0F7;
border-radius: 0;
cursor: pointer;
}
When I hover over the dropdown menu it doesn't show left-most border of the dropdown box. How can I make it so that it shows up?

Transparent Bootstrap navbar

I am working on a website and I want the navigation (only home the homepage) to be transparent and the image to cover the full screen. This is what I have so far:
The nav-bar is styled in this way because that's how it is on the other pages.
This is my HTML:
<div class="container-fluid">
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top navbar-trans" id="mainNav">
<a class="navbar-brand js-scroll-trigger" href="#page-top">
<img class="logo" src="app/assets/images/bunklogo.png" alt="bunk">
Bunk.
</a>
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fa fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#tenant">TENANT</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="landlord.html">LANDLORD</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#bunkfaqs">BUNK FAQs</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#blog">BLOG</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#team">TEAM</a>
</li>
<li class="nav-item">
<a class="nav-link js-scroll-trigger" href="#login">LOG IN</a>
</li>
<li class="nav-iten">
<button class="btn signup"> SIGN UP</button>
</li>
</ul>
</div>
</nav>
</div>
and my css:
#mainNav {
background-image: linear-gradient(90deg, #439EE0 0%, #26ADE6 100%);
/*margin-top: -0.5%;*/
padding-top: 1rem;
padding-bottom: 3rem;
margin-bottom: 0;
}
.navbar-toggler.navbar-toggler-right {
color:white;
border: 1px solid white;
font-size: 1.2rem;
padding: 1rem;
}
.navbar-light .navbar-nav .nav-link {
font-size: 1.2rem;
color: #ffffff;
letter-spacing: 0.8px;
text-align: center;
padding-right: 5rem;
}
.navbar-brand.js-scroll-trigger {
color: #ffffff;
font-size: 2rem;
}
Any suggestions?
There's no need for any custom css hacks here.
To make your Bootstrap navbar transparent, all you need is to remove the class bg-light.
That's it!
The bg in bg-light stands for "background". So, if you leave out the class for background color, you automatically have a transparent navbar.
Ok, first of all you need to separate the home page from the other pages. To do this just insert an ID on your body section like #home.
So, in this scenario you will add the following:
body#home #mainNav {
background:transparent;
background-image:none;
position:absolute;
width:100%;
left:0px;
right:0px;
top:0px;
}
Don't forget that your Slider (or w/e you have after #mainNav), maybe will need some padding-top equals to the #mainNav height, for example (in case that your #mainNav height is 50px):
.slider {
padding-top:50px;
}
You can give an extra class to your navbar on your index.html only. (or your homepage html file name.)
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top navbar-trans navbar--home" id="mainNav">
Then you can select this class like :
#mainNav.navbar--home{
background:transparent;
}
Use home page body class, for ex.: ".home / .home-index / .index-page" as a parent of ".nav.fixed-top" container.
CSS::
.home .nav.fixed-top{
background:rgba(0, 0, 0, 0) none repeat scroll 0 0;
}

Custom font breaks caret's position in Bootstrap navbar

While using Bootstrap 3 with custom font in navbar the position of carot doesn't remain vertically aligned with text.
I'm not using any custom classes - just li elements with .active and .dropdown respectively, only font-family was changed. I guess that the issue has to do with font's height itself.
How can I fix this issue without hacking carot's position? I'm building Bootstrap with LESS, so if there are any relevant variables corresponding for something like basic font height (or maybe line-height?) let me know.
Edit: Providing code example (just an ordinary navbar)
<nav class="navbar navbar-default">
<div class="container">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">
About <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
<li class="dropdown">
Link <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container -->
</nav>
The caret already has a class in bootstrap. I would recommend using that for positioning.
.caret {
display: inline-block;
width: 0;
height: 0;
margin-top: -10px;
margin-left: 2px;
vertical-align: middle;
border-top: 4px dashed;
border-top: 4px solid \9;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}
You can put the caret in a span:
<li class="dropdown">
<a class="dropdown-toggle" style="font-size: large" data-toggle="dropdown" href="#">HasDropdowns<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu1">

Why is there so much of right margin before my user icon?

I have a aside which is of 260px width. when i try to place my user-icon and name info, there is too much of right-margin.
<div class="rightBox pull-right" href="#">
<ul class="navbar-nav navbar-right">
<li class="dropdown">
<li style="margin-top: 3px">
<i class="fa fa-2x fa-border fa-user"></i>
</li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<label class="navbar-text" style="margin-top: 5px;margin-left:0;">
<strong><h4>
<span>Karl Cadigan</span>
<b class="glyphicon glyphicon-chevron-down"></b>
</h4></strong>
</label>
</a>
</ul>
</div>
Below is my fiddle. I want to bring the user-icon and the user-name to left leaving the drop-down icon at right.
http://jsbin.com/kugudaho/6/edit
Add the following class in your CSS. Use display:inline-block to show the info next to each other.
ul.navbar-nav
{
position:relative;
}
ul.navbar-nav li {
list-style: none;
display:inline-block;
}
.glyphicon{position:absolute; right:15px; top:15px;}
DEMO
If I understand it right this is what you need
HTML Markup
<div class="rightBox" href="#">
<ul class="navbar-nav">
<li class="dropdown">
<li style="margin-top: 3px">
<i class="fa fa-2x fa-border fa-user"></i>
</li>
<li class="glyph">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<label class="navbar-text" style="margin-top: 5px;margin-left:0;">
<strong><h4>
<span>Frank</span>
<b class="glyphicon glyphicon-chevron-down"></b>
</h4></strong>
</label>
</a>
</ul>
</div>
CSS
i {
list-style: none;
}
.rightBox{ height: 60px; width:260px; border:1px dashed red; }
.fa-user {
position: relative;
background: #666666;
}
.fa-user:after {
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 0 15px 15px 0;
border-color: transparent #89cd17 transparent transparent;
}
.navbar-nav li.glyph {
float: right !important;
}
.navbar-nav {
float: inherit;
padding-left: 10px;
}
I hope I understood what you need.
I think you're better off starting with a standard Bootstrap dropdown, and customizing where needed. Uses a lot less custom CSS (if any) and is easier to maintain...
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-2x fa-border fa-user"></i> <!-- put this inside the a element to bind it to the text -->
Frank
<span class="glyphicon glyphicon-chevron-down"></span> <!-- bootstrap used the class "caret" to designate a dropdown, but you can change it with a glyphicon if you need to -->
</a>
<ul class="dropdown-menu">
<li>Choice1</li>
<li>Choice2</li>
<li>Choice3</li>
</ul>
</div>
Example:http://www.bootply.com/f9WYqJqLmd

twitter bootstrap button group with transparent background

I have a button group using twitter bootstrap as you see here:
http://jsfiddle.net/rmk7H/
It makes a linear-gradient background:
linear-gradient(to bottom, #FFFFFF, #E6E6E6)
which is annoying me. I want it to have a transparent background by adding mynav class. How should I modify mynav class?
HTML:
<div class="btn-group mynav">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Username
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<ul class="nav nav-list">
<li class="nav-header">List header</li>
<li class="active">Home</li>
<li>Library</li>
...
</ul>
</ul>
</div>
CSS:
.mynav
{
}
You need to make the background of the a transparent add this
.mynav > a {
background:none;
border:none;
box-shadow:none;
}
http://jsfiddle.net/rmk7H/2/
Transparant, like this?
.mynav .btn
{
background-image: none;
}

Resources