I am working on improving my portfolio website (www.kikidesign.net) and am currently working on the footer. I'm trying to make it responsive in which the link (with the icon) will be able to stay the same but will be re-arranged in response to the browser window. For example, for desktop version, it will be in one line, but for tablet version, it will be two lines with two links in each row, and for mobile version, it will be like a list. However, I couldn't keep the icon and text in one place. When I move the browser window around, the icons keep popping out of their place. What should I do to fix it?
HTML
<div id="footercontent">
<ul class="ca-menu">
<li class="about2">
<a href="<?php echo get_option('home'); ?>/about" >
<span class="aboutimg"></span>About Me
</a>
</li>
<li class="contact2">
<a href="<?php echo get_option('home'); ?>/contact" >
<span class="contactimg"></span>Contact
</a>
</li>
<li class="download">
<a href="kikidesignResume.pdf">
<span class="downloadimg"></span>Resume
</a>
</li>
<li class="facebook">
<a href="https://www.facebook.com/kikidesignnet" >
<span class="facebookimg"></span>Facebook
</a>
</li>
</ul>
</div>
CSS
#footercontent {
position: relative;
padding-top: 15px;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
min-height: 100px;
}
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
width: 23%;
height: 100%;
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
#footercontent .ca-menu li a {
text-decoration: none;
text-align: left;
font-family: 'PrintClearlyRegular';
font-weight: normal;
font-style: normal;
font-size: 1.75em;
}
#footercontent .ca-menu li a:hover {
text-decoration: underline;
text-decoration-color: white;
-moz-text-decoration-color: white;
-webkit-text-decoration-color: white;
-o-text-decoration-color: white;
-ms-text-decoration-color: white;
}
.ca-menu li:hover .aboutimg, .ca-menu li:hover .contactimg, .ca-menu li:hover .downloadimg, .ca-menu li:hover .facebookimg {
color: #ffffff;
/**font-size: 30px;**/
opacity: 1;
}
.aboutimg {
display: inline-block;
width: 50px;
height: 60px;
text-align: center;
background: url(images/girlIcon2.png) no-repeat 0 0;
opacity: 0.3;
vertical-align: middle;
margin-top: -10px;
margin-right: 10px;
}
.ca-menu .about2 a {
color: #f9a145;
border: none;
text-decoration: none;
}
#contactimg {
padding: 15px 0 12px 0;
}
.contactimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/contact.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .contact2 a {
color: #4595d1;
border: none;
text-decoration: none;
padding: 20px;
}
.downloadimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/download.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .download a {
color: #f7e400;
border: none;
text-decoration: none;
padding: 20px;
}
.facebookimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/facebook.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .facebook a {
color: #B0B0B0;
border: none;
text-decoration: none;
padding: 20px;
}
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
I have made changes to those two part.
And for mobile:
#media (max-width: 480px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 100%;
}
}
You can do same for other sizes also:
#media (min-width: 480px) and (max-width: 720px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 40%;
}
}
DEMO
Related
I'm sorry to ask this question because it has been largely posted, but I checked a lot of links and didn't solve it yet. I have a navbar with 2 elements and I cannot center it in the middle of the nav.
#menu {
background: #000000;
background: linear-gradient(to bottom, #973F8E, #DC4069);
color: #FFF;
height: 52px;
width: 500px;
padding-left: 18px;
border-radius: 50px;
border: 1px solid #000000;
margin: auto;
display:block;
text-align:center !important;
}
#menu ul, #menu li {
margin: 0 auto;
padding: 0;
list-style: none;
display: block;
text-align: center;
}
#menu ul {
width: 100%;
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 50px;
padding: 0 14px;
text-decoration: none;
color: #FFFFFF;
font-size: 15px;
text-transform: uppercase;
}
#menu a.dropdown-arrow:after {
content: "\25BE";
margin-left: 5px;
}
#menu li a:hover {
color: #000000;
background: #FFA6AF;
}
#menu input {
display: none;
margin: 0;
padding: 0;
height: 52px;
width: 100%;
opacity: 0;
cursor: pointer
}
#menu label {
display: none;
line-height: 50px;
text-align: center;
position: absolute;
left: 35px
}
#menu label:before {
font-size: 1.6em;
content: "\2261";
margin-left: 20px;
}
#menu ul.sub-menus{
height: auto;
overflow: hidden;
width: 170px;
background: #444444;
position: absolute;
z-index: 99;
display: none;
}
#menu ul.sub-menus li {
display: block;
width: 100%;
}
#menu ul.sub-menus a {
color: #FFFFFF;
font-size: 16px;
}
#menu li:hover ul.sub-menus {
display: block
}
#menu ul.sub-menus a:hover{
background: #F2F2F2;
color: #444444;
}
<nav id="menu">
<input type='checkbox' id='responsive-menu' onclick='updatemenu()'><label></label>
<ul>
<li><a href='/'>DASHBOARD</a></li>
<li><a href='/model'>MODEL</a></li>
</ul>
</nav>
Probably in the large number of css elements I'm not able to see where the code is not working.
I posted the code here:
codepen
You should remove the left padding from the main #menu element, set the ul's display to inline-block and the width to auto (just remove the width property).
This will work because the #menu element has text-align: center. the ul will be centered since its width is not 100% (because width is set to auto and the display to inline-block).
#menu {
background: #000000;
background: linear-gradient(to bottom, #973F8E, #DC4069);
color: #FFF;
height: 52px;
width: 500px;
padding-left: 0; // remove this
border-radius: 50px;
border: 1px solid #000000;
margin: auto;
display:block;
text-align:center !important;
}
#menu ul, #menu li {
margin: 0 auto;
padding: 0;
list-style: none;
display: block;
text-align: center;
}
#menu ul {
display: inline-block; // and set this
}
#menu li {
float: left;
display: inline;
position: relative;
}
#menu a {
display: block;
line-height: 50px;
padding: 0 14px;
text-decoration: none;
color: #FFFFFF;
font-size: 15px;
text-transform: uppercase;
}
#menu a.dropdown-arrow:after {
content: "\25BE";
margin-left: 5px;
}
#menu li a:hover {
color: #000000;
background: #FFA6AF;
}
#menu input {
display: none;
margin: 0;
padding: 0;
height: 52px;
width: 100%;
opacity: 0;
cursor: pointer
}
#menu label {
display: none;
line-height: 50px;
text-align: center;
position: absolute;
left: 35px
}
#menu label:before {
font-size: 1.6em;
content: "\2261";
margin-left: 20px;
}
#menu ul.sub-menus{
height: auto;
overflow: hidden;
width: 170px;
background: #444444;
position: absolute;
z-index: 99;
display: none;
}
#menu ul.sub-menus li {
display: block;
width: 100%;
}
#menu ul.sub-menus a {
color: #FFFFFF;
font-size: 16px;
}
#menu li:hover ul.sub-menus {
display: block
}
#menu ul.sub-menus a:hover{
background: #F2F2F2;
color: #444444;
}
You can use flex positions.
Use property justify-content : center to center all children div inside a parent div. It's useful to distribute the space between or around the elements.
This will also make your CSS code lighter. The more CSS, the more difficult it is.
It's also good for responsive design.
I have also removed some CSS property. This code can be further improved and reduced. Good luck !
#menu {
background: #000000;
background: linear-gradient(to bottom, #973F8E, #DC4069);
color: #FFF;
height: 52px;
width: 500px;
// padding-left: 18px;
border-radius: 50px;
border: 1px solid #000000;
margin: auto;
// display:block;
// text-align:center !important;
}
#menu ul, #menu li {
margin: 0 auto;
padding: 0;
// list-style: none;
// display: block;
text-align: center;
}
#menu ul {
width: 100%;
display: flex;
justify-content: center;
}
#menu li {
// float: left;
margin : 0px;
display: inline;
// position: relative;
}
#menu a {
display: block;
line-height: 51px;
padding: 0 14px;
text-decoration: none;
color: #FFFFFF;
font-size: 15px;
text-transform: uppercase;
}
#menu a.dropdown-arrow:after {
content: "\25BE";
margin-left: 5px;
}
#menu li a:hover {
color: #000000;
background: #FFA6AF;
}
#menu input {
display: none;
margin: 0;
padding: 0;
height: 52px;
width: 100%;
opacity: 0;
cursor: pointer
}
#menu label {
display: none;
line-height: 50px;
text-align: center;
position: absolute;
left: 35px
}
#menu label:before {
font-size: 1.6em;
content: "\2261";
margin-left: 20px;
}
#menu ul.sub-menus{
height: auto;
overflow: hidden;
width: 170px;
background: #444444;
position: absolute;
z-index: 99;
display: none;
}
#menu ul.sub-menus li {
display: block;
width: 100%;
}
#menu ul.sub-menus a {
color: #FFFFFF;
font-size: 16px;
}
#menu li:hover ul.sub-menus {
display: block
}
#menu ul.sub-menus a:hover{
background: #F2F2F2;
color: #444444;
}
<nav id="menu">
<input type='checkbox' id='responsive-menu' onclick='updatemenu()'><label></label>
<ul>
<li><a href='/'>DASHBOARD</a></li>
<li><a href='/model'>MODEL</a></li>
</ul>
</nav>
I was wondering but I have been spending a lot of time trying to find a way to make my li from my ul stretch across but I seem not to be able to do it. It's very similar to the nav bar of This website and This website.I am asking if someone can help me with this.
Thank you. Best I can provide is a basic nav hover bar
.dropdown-btn {
width: 100%;
height: 50px;
background: white;
line-height: 50px;
display: none;
}
nav {
width: 100%;
height: 50px;
background-color: #d60d8c;
margin-bottom: 1px;
position: sticky;
top: 0;
padding: 0px 0px;
border: none;
}
ul {
text-indent: 0px;
}
nav:hover {
height: 50px;
}
.navbar-tab {
display: block;
}
.hover-list {
position: absolute;
}
.navbar-tab-1 {
background: #d60d8c;
float: left;
border: none;
}
.navbar-tab-1+.navbar-tab-1 {
border-bottom: none;
}
.hover-list {
border-top: black 3px solid;
}
.navbar-tab {
padding-left: 20px;
display: block;
}
.navbar-tab {
max-width: 1240px;
}
.navbar-tab-1 {
padding-right: 68px;
width: auto;
}
.hover-list li {
background-color: #e2e2e2;
border-bottom: 1px white solid;
font-size: 15px;
text-indent: 20px;
height: 35px;
line-height: 35px;
width: 100vw;
border-top: none;
float: left;
}
ul li ul li {
display: block;
}
ul li {
font-size: 19px;
}
ul {
padding: 0px;
list-style: none;
font-family: arial;
margin: auto;
}
.navbar-tab-1:hover {
color: black;
transition-duration: .2s;
}
ul li {
font-family: 'Raleway', sans-serif;
font-weight: 400;
line-height: 50px;
list-style: none;
}
ul li a {
text-decoration: none;
color: black;
}
ul li ul li{
display: none;
transition-duration:
}
.hover-list li:hover{
background-color: #f5f5f0;
transition-duration: .2s;
}
<nav id="navbar">
<div class="dropdown-btn">Go To...</div>
<ul class="navbar-tab">
<li class="navbar-tab-1 selected">Test1</li>
<li class="navbar-tab-1 select">
Test2
<ul class="hover-list select">
<li>Item1</li>
</ul>
</li>
</ul>
</nav>
Maybe something you are looking for
body {
margin:0;
}
.dropdown-btn {
width: 100%;
height: 50px;
background: white;
line-height: 50px;
display: none;
}
nav {
width: 100%;
height: 50px;
background-color: #d60d8c;
margin-bottom: 1px;
position: sticky;
top: 0;
padding: 0px 0px;
border: none;
}
ul {
padding-left: 0;
position: relative;
list-style: none;
margin-bottom: 0;
}
nav:hover {
height: 50px;
}
.navbar-tab {
display: block;
}
.hover-list {
position: fixed;
max-height: 0;
transition: max-height 1s;
padding: 0;
width: 100vw;
overflow: hidden;
left: 0;
top: 66px;
}
.hover-list > li {
width: 100%;
}
.navbar-tab-1 {
background: #d60d8c;
float: left;
border: none;
}
.navbar-tab-1+.navbar-tab-1 {
border-bottom: none;
}
.navbar-tab {
padding-left: 20px;
display: block;
}
.navbar-tab {
max-width: 1240px;
}
.navbar-tab-1 {
padding-right: 68px;
width: auto;
}
.hover-list li {
background-color: #e2e2e2;
border-bottom: 1px white solid;
font-size: 15px;
text-indent: 20px;
height: 35px;
line-height: 35px;
border-top: none;
float: left;
}
ul li ul li {
display: block;
}
ul li {
font-size: 19px;
}
ul > li:hover ul {
max-height: 500px;
}
<nav id="navbar">
<div class="dropdown-btn">Go To...</div>
<ul class="navbar-tab">
<li class="navbar-tab-1 selected">Test1</li>
<li class="navbar-tab-1 select">Test2
<ul class="hover-list select">
<li><a>Item1</a></li>
</ul>
</li>
</ul>
</nav>
When hovering over the links in drop2 div, the entire drop2 div moves upward a few pixels. Same problem with drop3.
Any ideas why the div is shifting up when I hover over it? Thank you, any advice much appreciated.
#nav {
background-color: #373737;
float: left;
height: 30px;
padding: 0px 0px 0px 0px;
width: 970px;
}
.nav a {
display: block;
}
.nav ul li a {
position: relative;
}
a {
text-decoration: none;
}
a.item {
color: white;
}
.item {
position: relative;
}
a.item:hover {
background-color: #dcd0c0;
height: 30px;
color: #373737;
font-weight: bold;
}
.menu {
list-style-type: none;
margin: auto;
width: 970px;
text-align: center;
}
.nav .items {
display: inline;
float: left;
margin: 0px 100px 0px 100px;
padding: 0;
text-align: center;
width: 82px;
}
.drop2 {
display: none;
text-align: left;
width: 150px;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
}
.items:hover .drop2 {
display: block;
width: 150px;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
background-color: #f4f4f4;
position: relative;
z-index: 99;
}
.drop3 {
display: none;
text-align: left;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
width: 150px;
}
.items:hover .drop3 {
display: block;
width: 150px;
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
background-color: #f4f4f4;
position: relative;
z-index: 99;
}
.drop2 > a {
color: #373737;
}
.drop3 > a {
color: #373737;
}
.drop2 > a:hover {
font-weight: bold;
}
.drop3 > a:hover {
font-weight: bold;
}
<div id="nav">
<div class="nav">
<ul class="menu">
<li class="items">
Photos
</li>
<li class="items">
Locations
<div class="drop2">
Bays
Lakes
Pacific Ocean
</div>
</li>
<li class="items">
Catches
<div class="drop3">
Bass
Other
</div>
</li>
</ul>
</div>
</div>
Add line-height: 30px; to your #nav tag in css.
jsfiddle
The drop-down menu wont work for my navigation. It gets hidden with display:none but upon hovering nothing is shown even though i specified that when the anchor tag containing the UL is hovered over display the child elements as blocked.
html:
<body>
<header id = "M_head">
<h2><ul>MC</ul></h2>
</header>
<div id="container">
<nav id="M_nav">
<ul>
<a>NEWS<img class="Nav_down1" src="Nav_down1.png">
<ul>
<li><a>ting1</a></li>
</ul>
</a>
<a>STORE<img class="Nav_down1" src="Nav_down1.png"></a>
<a>BLOG<img class="Nav_down1" src="Nav_down1.png"></a>
<a>CONTACTS<img class="Nav_down1" src="Nav_down1.png"></a>
<a>ABOUT<img class="Nav_down1" src="Nav_down1.png"></a>
</ul>
</nav>
<section id="M_section">
<div id=Side_sec></div>
<div id="Side_sec2"></div>
</section>
<footer id="M_footer">
</footer>
</div>
</body>
css:
* {
box-sizing: border-box; }
body {
max-width: 100%;
margin: 0px;
display: block; }
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat; }
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em; }
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em; }
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table; }
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black; }
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none; }
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none; }
#M_nav ul ul {
display: none; }
#M_nav ul > a:hover > ul {
display: block; }
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right; }
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white; }
here is the Jsfiddle link:http://jsfiddle.net/va06bfav/
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul li {
float: left;
position: relative;
}
#M_nav ul ul {
display: none;
position: absolute;
width: 157px;
top: 34px;
left: 0px;
list-style: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
If you see your code in dev tool you can see that Ul which is your drop down menu is not immediate children of your anchor tag it is placed after anchor tag immediately. The selector you are using is X > Y which selects direct children (please see the link for more detailed information about css selector.)
Changes i have made
Changed your markup structure added li in it which was not there earlier and causing the weird behavior of drop down menu which i have mentioned above.
Changed your css selector from X > Y to X X + Y what this selector will do ,It will select only the element that is immediately preceded by the former element.
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul ul {
display: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a></li>
</ul>
</li>
</ul>
</nav>
</div>
I am using a ul & li a bit like a select dropdown to trigger a JS function (not shown).
It's working fine - except the menu items appear BEHIND divs that are shown below them.
I've mocked up the problem here: http://jsfiddle.net/bf8ugef7/1/
I'm fiddling with z-index and position:absolute but can't see how to make it work.
Can anyone help?
Here is the HTML and CSS:
body {
font-family: sans-serif;
color: gray;
font-weight: 100;
}
div, li {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
li {
color: #333333;
text-decoration: none;
/* background-image: url("images/mullion.gif"); */
}
div.images {
border: 1px solid #555555;
/* padding-left: 5px; */
width: 100%;
float: left;
clear: left;
margin-bottom: 20px;
/*
background-image: url("images/iMullion.gif");
background-repeat: no-repeat;
*/
}
div.lowerText {
width: 100%;
}
div.btn {/* +filter */
float: right;
width: 195px;
cursor: default;
text-align: right;
/* margin-left: 1px; */
display: inline-block;
}
div.btn1 {
float: left;
width: 153px;
cursor: default;
text-align: center;
margin-left: 1px;
display: inline-block;
position: absolute;
color: black;
background-color: #79c1ee;
left: 182px;
}
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
position: absolute;
left: 162px;
z-index: 100;
}
div.btn2 ul {
list-style: none;
position: absolute;
display: block;
margin: 0px;
padding: 0px;
z-index: 100;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
margin-top: 1px;
z-index: 100;
}
div.btn2 ul li:first-child {
margin-top: 0px;
display: inline-block;
width: 20px;
z-index: 100;
}
div.btn2 ul:hover {
height: 200px;
}
div.btn2 ul:hover li {
display: block;
z-index: 100;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
z-index: 100;
}
/*
div.btn2 ul li:hover {
display: block;
width: 20px;
height: 100px;
}
*/
div.btn3 {
margin-left: 1px;
float: left;
width: 20px;
display: inline-block;
vertical-align: top;
text-align: center;
font-weight: 400;
color: white;
background-color: #13A3E2;
position: absolute;
left: 336px;
cursor: pointer;
}
div.btn3:hover {
background-color: red;
}
div.btn4 {
/* border: 1px solid black; */
padding-left: 5px;
float: left;
width: 153px;
display: inline-block;
color: #444444;
cursor: default;
background-color: white;
}
div.attr {
padding-left: 5px;
color: #444444;
background-color: #79C1ED;
float: right;
clear: none;
display: inline-block;
text-align: left;
}
div.filters {
width: 100%;
line-height: 1.8;
overflow: hidden;
display: block;
font-size: 14px;
text-decoration: none;
float: left;
}
div.toptext {
line-height: 2.2;
display: block;
max-height: 35px;
color: #444444;
background-color: #555555;/* matches border color */
color: white;
width: 100%;
padding-left: 5px;
cursor: not-allowed;
/* border: 1px solid pink; */
}
div.leftnav {
width: 350px;
float: left;
clear: left;
}
div#container {
padding: 0px;
margin: 0px;
}
<div class="leftnav">
<div class="images">
<div class="toptext">Filters
<div class="btn">+ filter</div>
</div>
<div id="container">
<div class="filters rem" id="f12">
<div class="btn4" id="b4f12">Pupil name</div>
<div class="btn2" id="b2f12">
<ul>
<li id="ddf_12_0">=</li>
<li id="ddf_12_1">></li>
</ul>
</div>
<div class="btn1" id="b1f12">Joe Bloggs</div>
<div class="btn3" id="if12">x</div>
</div>
<div class="filters rem" id="f13">
<div class="btn4" id="b4f13">Pupil name</div>
<div class="btn2" id="b2f13">
<ul>
<li id="ddf_13_0">=</li>
<li id="ddf_13_1">></li>
</ul>
</div>
<div class="btn1" id="b1f13">Bill Clinton</div>
<div class="btn3" id="if13">x</div>
</div>
</div>
</div>
</div>
Thanks
Emma
Try this code:
div.btn2 {
float: left;
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
background-color: white;
cursor: default;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
border-top: none;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
border-top: 1px solid #fff;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
# Claudiu Yes it should be comment, but i dont have enough points to add comments
div.btn2 {
width: 20px;
display: inline-block;
color: white;
font-weight: 100;
text-align: center;
cursor: pointer;
left: 162px;
}
div.btn2 ul {
display: block;
margin: 0;
padding: 0;
}
div.btn2 ul li {
display: none;
cursor: pointer;
color: white;
height: 25px;
background-color: #79c1ee;
}
div.btn2 ul li:first-child {
display: inline-block;
width: 20px;
}
div.btn2:hover li {
display: block;
position: absolute;
width: 20px;
background: #000;
}
div.btn2:hover li:first-child {
position: relative;
}
div.btn2 ul li:hover {
background-color: #13A3E2;
}
i have updated the fiddle