Controlling bootstrap dropdown menu with it's grid system - css

I am using bootstrap framework for a project and having a tiny problem with dropdown menu. Here is the link;
http://erkano.com/neu
You will see when you hover over "YÖNETİM" button that the dropdown appears. I, however, want this dropdown has the same width value, that is col-md-5, with the whole menu bar. The reason I could not deal with it is that the dropdown should stay in the first button, that is col-md-2 in the col-md-5.
Do you have any idea?
Thanks in advance

Okay now that I understand the question.
You can make the dropdown menu full width by... give that drop down menu the class container.
<ul class="dropdown-menu main-menu-dropdown container" id="menu1">
I quickly did this from inspecting and it made it almost full width.. this in practice kinda of works. You get the idea of making the drop down a set width and using javascript to make it responsive...
But I also did this and it kinda of work as well. Your layout is weird and breaks responsively anyways but here I changed the class:
.dropdown:hover .dropdown-menu {
display: block;
width: 95%; <-- I added this
}
and
dropdown-menu {
position: fixed; <-- changed to fixed instead of absolute
top: 13%; <-- changed to 13% instead of 100%
left: 0px;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0px;
margin: 2px 0px 0px;
list-style: outside none none;
font-size: 14px;
background-color: #FFF;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.176);
background-clip: padding-box;
}
you can fiddle with the css to get the exact size you want but that in a nutshell will work.

<div class="dropdown main-menu-dropdown-container">
<li class="col-md-2">
YÖNETİM
</li>
<ul class="dropdown-menu main-menu-dropdown col-md-12" aria-labelledby="main-menu-dropdown-1">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
</ul>
</div>
I have edited the html part like this and the css part like this;
.main-menu-dropdown-container:hover .dropdown-menu {
display: block;
}
.main-menu-dropdown {
height: 260px;
border-radius: 0 !important;
margin-top: 0px !important;
top: 60px !important;
border:0 !important;
border-top:1px solid #F3F3F3 !important;
-webkit-box-shadow: 5px 5px 14px -9px rgba(0,0,0,0.59) !important;
-moz-box-shadow: 5px 5px 14px -9px rgba(0,0,0,0.59) !important;
box-shadow: 5px 5px 14px -9px rgba(0,0,0,0.59) !important;
}
This works perfectly for me. I did not even change anything on the original grid system and the dropdown system on bootstrap.

Related

How to create two borders - Pure CSS

I am simply trying to achieve the same effect as in the image below*. I want the Header to have two borders, one is lighter than the other to give it an embossed feel.
Before I asked this question on here, I have already done some research and tried ideas inspired from websites like: CSS-Tricks, Daverupert ect... But they are adding Outlines - and after trying that it didn't really work on modern browsers so how about the old ones!
*Since I am now allowed to post an image at this time, please refer to this link for an image: http://postimg.org/image/4b6ne0qod/
Please take a look at my website here: leo.meeped.co.uk Look at the header - you will also notice that it has a shadow after the think border that makes it look like it's edge has been folded.
Update: I very like this folding effect, however it makes the header fade out a bit / not stand-out when you scroll down to a white or gray page - as it seem like the shadow blend with the page since they are a very relative colours. So the idea was to add anther border just under the current border to make to emphasise it's edge.
Hope my question is clear, I am looking for your opinions and help.
In case you want the HTML and CSS of my site then here it is:
<!--Header--><header>
<div id="headerWrapper">
<div id="headerContent">
<div id="headerLogo">
<img alt="loai design studio logo" src="assets/elements/logo.png"/>
</div>
<nav><ul id="mainMenu" class="snapjs-expand-left">
<li>Home</li>
<li>Portfolio
<li>About Me</li>
<li><a class="active" href="contact.html">Contact Me</a></li>
<li>Blog</li>
</ul></nav>
</div>
</div>
</header>
/*HEADER////////////////////////////////////////////*/
/*Header Wrapper*/#headerWrapper {
background-color: #FFFFFF;
border-bottom: 5px solid #E8E8E8;
width: 100%;
position: fixed;
top: 0; left: 0;
z-index: 1000;
-webkit-box-shadow: 0px 0px 20px -3px rgba(0,0,0,0.20);
-moz-box-shadow: 0px 0px 20px -3px rgba(0,0,0,0.20);
box-shadow: 0px 0px 20px -3px rgba(0,0,0,0.20);
}
/*Header Content Container*/#headerContent {
padding: 0 20px;
}
/*Header Logo*/
#headerLogo {
width: 130px;
margin: 19px 0;
float: left;
}
/*Main Menu*/
#mainMenu {
float: right;
margin: 17px 0;
}
#mainMenu li {
float: left;
}
#mainMenu a {
padding: 10px 15px;
margin-left: 3px;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
#mainMenu a:hover {
color: #FFFFFF;
background-color: #4E6C98;
}
#mainMenu a.active {
color: #4E6C98;
cursor: default;
}
#mainMenu a.active:hover {
background-color: rgba(0, 0, 0, 0);
background: rgba(0, 0, 0, 0);
background: transparent;
}
If you simply want two borders without using CSS's outline property, why don't you simply create a border bottom for div#headerWrapper and one for div#headerContent making that of headerWrapper darker:
div#headerWrapper
{
border-bottom: solid 1px #3D9ED5;
}
div#headerContent
{
border-bottom: solid 1px #81CEFA;
background-color: #54BEFB;
}
If you want the exact appearance of your picture, you can do so by adding the following code (assuming that the part below the border should be empty):
header
{
height: 50px;
background-color: #FBFBFB;
}
If text should be inserted into the lower half of the picture, add it after the outer div (in header) and remove the height from the CSS.
Try using CSS box shadows to create "shadows". For example:
#headerWrapper {
box-shadow: 0 1px 0 rgba(255,0,0,0.8), 0 2px 0 rgba(0,255,0,0.8);
}
Each new shadow should be separated by a comma.
Does this do what you were wanting?
The browser support is pretty good for box shadows now but you might want to keep it in mind. Pretty much everything except IE8 supports it if you use all the vendor prefixes, for more info see: http://caniuse.com/css-boxshadow

Overflow issue in cascading CSS menu

I have a simple CSS-based drop down menu that is working fine. But now I want to add a sub-menu that will display as well. Everything is working fine, except the height on the main menu list is expanding when the sub menu is displayed.
http://jsfiddle.net/GzfFs/
.cascade_content {
/* cascading sub menu */
display: none;
z-index: 103;
position: relative;
background: #FFFFFF;
border: 1px solid #8C8C8C;
padding: 10px 0px 10px 0px;
width: 190px;
left: -192px;
top: -26px;
-moz-box-shadow: 0 2px 6px 0px #8C8C8C;
-webkit-box-shadow: 0 2px 6px 0px #8C8C8C;
box-shadow: 0 2px 6px 0px #8C8C8C;
}
Note: it seems like position:relative in the sub menu is causing this... however, changing that to position:absolute creates the problem of it not appearing in the right place. I'm sure those of you with more CSS experience will identify this as a simple issue - appreciate any help you can offer!
http://jsfiddle.net/GzfFs/1/
.dropdown_content li {position: relative}
.cascade_content {position: absolute}
You may also need to move your ULs inside the LIs to get positioning where you want it.

Sliding Highlight in Nav Bar

I currently have this on a webpage I'm making:
HTML
<div id="pageHeader">
<nav id="siteNav">
<ul>
<li id="currentNavTab"><span>Home</span></li>
<li><span>Services</span></li>
<li><span>Gallery</span></li>
<li class="LastNavTab"><span>Contact</span></li>
</ul>
</nav>
</div>
CSS
nav#siteNav {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
nav#siteNav ul {
padding: 0;
background-image: url('NavTabsBG.jpg');
box-shadow: inset 0px 2px 8px 2px rgba(0, 0, 0, 0.4);
border-radius: 8px;
}
nav#siteNav li {
display: inline;
width: 240px;
padding-left: 50px;
padding-right: 50px;
}
nav#siteNav a {
display: inline-block;
padding: 10px;
color: rgb(255, 235, 200);
font-size: 36px;
text-shadow: 0px 2px 0px rgba(0, 0, 0, 0.6);
}
The code results in something like this:
I would like to have it so that the currently selected tab takes on a highlight, which can either be a bitmap or generated with background-gradient; something like this mockup:
I'm having issues with the layout. I tried to put the background behind the li's, but that didn't display correctly:
Being a relative amateur at web development I don't know how to fix this and get the result I want. An additional issue is that I would like the highlight to be masked within the rounded border. Any help would be appreciated!
Here's a fiddle. http://jsfiddle.net/57VC8/1/
What i did:
Set display inline-block on the li's. Why? Putting inline-blocks or block (that's elements with one of those displays) inside inline elements just might give you some hard to understand problems.
Set all the width's and paddings on the a element and not on the li.
Added a class "current" to the currently selected link, through which you'd apply whichever styles you want.

border-radius issue CSS

Having a bit of an issue with border-radius. I have successfully rounded off my rectangle, but I am having an issue with rounding the hover that I have placed over it. You will see in the top and bottom corners of the rounded rectangle the hover itself is not rounded and is actually a rectangle. I have tried rounding it but it rounds the center as well. I know this probably doesn't make sense but you will understand by looking here: http://jsfiddle.net/hCg3J/
All I want to do is to have each selection highlight the whole of that area, and not stick out.
HTML:
<ul class="pageitem">
<li class="list" style="border-top:none;">iPhone 4/4S</span><div class="arrow"></div></li>
<li class="list">iPhone 3G/3GS</span><div class="arrow"></div></li>
<li class="list">iPod Touch</span><div class="arrow"></div></li>
</ul>
CSS
.pageitem {
-webkit-border-radius: 8px;
behavior: url(/border-radius.htc);
border-radius: 8px;
position:relative;
zoom: 1;
-moz-border-radius: 8em;
-khtml-border-radius: 8px;
border-radius: 8px;
background-color: #fff;
border: #878787 solid 1px;
font-size: 12pt;
overflow: hidden;
padding: 0;
height: auto;
width: auto;
margin: 3px 9px 17px;
list-style: none
}
Just add proper -webkit-border-radius in .list:hover, name:hover and adjust it to your needs.
Here is a jsfiddle proof of concept. What you need to do is to round only top-left and top-right corner for top element and bottom-left, buttom-right for the bottom element. I would suggest adding a special class for these elements.
UPDATE:
Actually as I suggested in comment I have added first-child and last-child selectors, updated fiddle
.list:hover:first-child, name:hover:first-child {
-webkit-border-radius: 8px 8px 0px 0px;
}
.list:hover:last-child, name:hover:last-child {
-webkit-border-radius: 0px 0px 8px 8px;
}

Div with rounded corners and inset border breaks when expanding

This doesn't seem to be a problem in Firefox. But noticeable in Safari
I have a div with rounded corners, an inset border and a specified width. You can see it at http://jsfiddle.net/jsoningram/fek5n/
You'll notice the div breaks about midway down on the left. Well actually it doesn't break but appears to. If I change the color of the border in the .beveled class to black it's visible. I can also remove the border-style and the "missing link" is returned.
The html:
<div id="sub_nav" class="rounded_10 beveled">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
​
The css:
#sub_nav {
position: relative;
background: #e6e6e6;
width: 164px;
min-height: 300px;
float: left;
padding: 0px 0px 27px 0px;
z-index: 5;
margin: 10px 0 0 10px;
}
#sub_nav li {
position: relative;
height: 50px;
width: 160px;
background: #ccc;
margin: 0px 0px 1px 1px;
}
#sub_nav li:first-child {
margin-top: 27px;
}
.rounded_10 {
-webkit-broder-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
behavior:url(_/inc/PIE.htc);
}
.beveled {
border: 1px solid #fbfbfb;
border-style: inset;
}
Thanks in advance...​
This has to do with how border-style:inset works, and the fact that your border and background colors are so close to one another.
Inset is a 3-d style effect, but with a 1px border, it's having difficulty figuring out how to draw the effect. If you change
.beveled {border: 30px solid red; border-style:inset;}
You'll see what it's trying to accomplish. It takes the base color and then darkens/lightens it to make the effect. You light grey is getting lightening to white for a section of it.
So, remove the border-style:inset, and then change the border color, and you should be in business.
.beveled {border: 1px solid #ccc;}
I did a little bit of experimenting and found that the same problem appears when you manually create an inset border by setting each side like this.
.beveled {
border-top: 2px solid #aaa;
border-left: 2px solid #aaa;
border-right: 2px solid #efefef;
}'
I created a jsFiddle with the bare minimum css to show this problem.
http://jsfiddle.net/MdE7q/
It has something to do with the width to height ratio. Can't explain it but change the width on my example to 400px and the gap goes away. In fact the gap doesn't appear at all when width is greater than height, only when height is greater than width.
Also, this looks perfect in IE9+, which leads me to believe it is a rendering problem in webkit and firefox.
Maybe modernizr would help here. http://modernizr.com/
Wow. This is weird. If you make #sub_nav 180px wide then it seems to fix it.
http://jsfiddle.net/fek5n/11/

Resources