Toggle div container overlapping another container under it - css

I have 3 divs on a form page of my website. The top left toggle overlaps the bottom div whenever i click the toggle button.
What I'm trying to do is that the bottom left div container should move down when the top div container is clicked and move back to it's former position when toggle is closed.
I have included the css for the right div, I dont know if that is the css afecting the positions of the two div 's beside it.
Before Toggle
After Toggle
CSS for Toggle
#toggle-view {
list-style:none;
font-family:arial;
font-size:10px;
margin:0;
padding:0;
width:200px;
position: absolute;
}
#toggle-view li {
list-style:none;
text-decoration:none;
font-size:13px;
font-family:'lato';
padding:2px;
margin:10px;
margin-left:20px;
position:relative;
cursor:pointer;
border-radius: 5px;
}
#toggle-view li a:hover {
color: brown;
}
#toggle-view h3 {
margin:0;
font-size:13px;
color:#2a5a9a;
}
#toggle-view span {
position:absolute;
right:5px; top:0;
color:#2a5a9a;
font-size:20px;
font-weight: bolder;
}
#toggle-view p {
margin:5px 0;
display:none;
}
#toggle-view a{
padding:5px 0;
color:#35371c;
}
#toggle-view a:hover{
color:#2a5a9a;
}
CSS for LeftBox
.report{
position: absolute;
margin-top:100px;
margin-left:0;
padding-left: 20px;
}
CSS for Right Box
.register-body {
height:auto;
font-size:1em;
width:710px;
position:relative;
color:#000;
border-radius:5px;
background-color:#d2d4bb;
line-height:20px;
margin:20px 0 20px 250px;
padding:15px 15px 0;
}
UPDATE
When I changed
#toggle-view {
position: absolute;
}
to
#toggle-view {
position: relative;
}
and
.report{
position: absolute;
}
to
.report{
position: relative;
}
I got this :
The Right Box is pushed below the bottom left box.

It's because you're using position absolute. Try doing the layout without absolute positioning and then it will move and flex and bend to your almighty will! :)

Related

Have Buttons to the Left Move When One of the Buttons Are Hovered On, Too

When you hover on one of the menu buttons at http://hijinxnetwork.net/web.html, the buttons on the right, but not the buttons on the left. I would like the buttons on the left to move as well.
CSS:
#nav {
width:800px;
margin:0 auto;
}
#nav ul {
position:relative;
top:187px;
left:auto;
right:auto;
}
#nav li {
float:left;
display:inline;
display:block;
margin-left:3px;
margin-right:3px;
padding-left:20px;
padding-right:20px;
font-family: 'Roboto', sans-serif;
font-weight:100;
text-transform:uppercase;
font-size:24px;
background-color: #363636;
height:50px;
padding-top:20px;
transition: 1s;
position:relative;
left: 0;
}
#nav li:hover {
font-size:30px;
background-color:#a61919;
height:60px;
margin-right: -10px;
left: -10px;
margin-left:10px;
}
#nav li a {
color:#ffffff;
text-decoration:none;
}
Following your code, this should work:
#nav ul {
left: 0px;
right: 0px;
transition: 1s;
}
#nav ul:hover {
left: -5px;
right: -5px;
}
That would make buttons move equally to both sides. It adds the "expanding" animation to the ul element, 5 pixels on each side.

Fixed CSS positioning of nav menu on floating navbar

visualisation of problem: http://tinyurl.com/q83t89y
Is there a way to have the browse button to stay on the exact location that it is now?
For example if I resize my window or zoom in / out the browse button leaves its location.
Here is the css:
<style>
ul.Nav2 {
list-style-type:none;
margin:0 auto;
padding:0;
overflow:hidden;
width:auto;
}
ul.Nav2>li {
position:fixed;
top:0;
right: 25%;
padding:0px;
width:100px;
height:20px;
margin:10px;
z-index: 9999;
float: right;
}
ul.Nav2 li a {
font-family:"Arial";
font-size:15px;
color:#FFF;
display:block;
width:auto;
height:35px;
line-height:20px;
/*removed
text-align:center;
*/
text-decoration:none;
opacity:0.6;
padding:0px 10px;
;
;
;
-o-transition:all 0.2s ease-in-out;
transition:all 0.2s ease-in-out;
}
ul.Nav2 li a:hover {
opacity:1;
}
ul.Nav2 ul {
list-style:none;
position:absolute;
left:-9999px;
text-align:right;
float:right
/*added*/
display:block;
padding:0;
min-width:9.3ex;
}
ul.Nav2 ul li {
padding-top:1px;
float:none;
}
ul.Nav2 ul a {
white-space:nowrap;
}
ul.Nav2 li:hover ul {
left:inherit;
}
ul.Nav2 li:hover a {
text-decoration:none;
}
ul.Nav2 li:hover ul a {
text-decoration:none;
}
ul.Nav2 li:hover ul li a:hover {
}
</style>
The problem is that ul.Nav2>li has been positioned to the right side of the browser. I think you should leave it alone and...
Create a fixed container <div> like radio bar. (Green box in the example below)
Set an invisible <div> in the center of container. (Red box)
Position the Browse menu to the centered box. (Blue box) Use margin-left to avoid overlapping the radio-bar.
Example: http://jsfiddle.net/Stocki/ZGzb6/

CSS horizontal menu with variable width from parent div

I'm trying to create a horizontal menu with the width of the parent div and where the links are arranged in equal distances. Target is to create a navigation bar with a width of 900px. Maybe it is possible to realize it on another way? I'm a newbie in css and don't know how to fix my problem and hope you could help me!
#nav {
background:red;
width:900px;
}
ul#nav-bar, ul#nav-bar ul{
margin:0;
list-style:none;
padding:0;
background: white;
border: 1px solid black;
}
ul#nav-bar ul{
display:none;
position:absolute;
left:0;
}
ul#nav-bar li:hover>*{
display:block;
}
ul#nav-bar li{
position:relative;
display:block;
white-space:nowrap;
font-size:0;
float:left;
}
ul#nav-bar li:hover{
z-index:1;
}
ul#nav-bar{
font-size:0;
z-index:999;
position:relative;
display:inline-block;
zoom:1;
padding:0;
*display:inline;
}
* html ul#nav-bar li a{
display:inline-block;
}
ul#nav-bar>li{
margin:0;
}
ul#nav-bar a:active, ul#nav-bar a:focus{
outline-style:none;
}
ul#nav-bar a{
display:block;
vertical-align:middle;
text-align:center;
text-decoration:none;
font: 12px Arial;
color:#000000;
padding:5px 10px 5px 10px;
}
ul#nav-bar ul li{
float:none;
margin:0 0 0;
}
ul#nav-bar ul a{
text-align:left;
background-color:red;
color:#000;
}
ul#nav-bar li:hover>a{
background-color:#fff;
color:#000000;
}
ul#nav-bar span{
display:block;
overflow:visible;
background-position:right center;
background-repeat:no-repeat;
padding-right:0px;
}
<div id="nav">
<ul id="nav-bar">
<li>Link1</li>
<li><span>Link2</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link3</li>
<li><span>longxxxxxxxxxxxxxxxxxxxxxxxxxxxlink</span>
<ul>
<li>lowerLink1</li>
<li>lowerLink2</li>
<li>lowerLink3</li>
</ul>
</li>
<li>Link5</li>
<li>Link6</li>
<li>longxxxxxxxxxxxxxlink</li>
</ul>
</div>
Thanks!
To get the #nav-bar to match the parent, simply add width:100% to your existing ul#nav-bar tag in css. This tells your child to fill up the parent, regardless of child's content.
As for spreading out the links, it has been my experience that the best way to do this is to add margins to the text once the navbar is complete. For your coded example, I would add the following to even them out:
ul#nav-bar->li{
margin:0px 20px 0px 20px;
text-align:center;
}
You can view it here and here is the css code
/*zero-height container problem fix for floated elements*/
.clearfix:before,
.clearfix:after {
content:"";
display:table;
}
.clearfix:after {
clear:both;
}
#nav {
background:#999;
width:900px;
}
#nav ul{
list-style: none;
padding: 0;
margin: 0;
}
#nav li{
position: relative;
text-align: center;
padding: 10px 0px;
}
#nav a{
text-decoration: none;
display: block;
color: #f0f0f0;
}
#nav-bar > li{
float: left;
}
#nav-bar ul{
position: absolute;
left: 0;
width: 100%;
top: 100%;
background: #999;
display: none;
}
#nav-bar li:hover{
background: #666;
}
#nav-bar li:hover ul{
display: block;
}
As if you want width to be adjusted to text width in li elements so you need javascript
and here is the code i have updated the jsfiddle
$(document).ready(function(){
total_nav_width = $('#nav').width();
main_link = $('#nav-bar > li > a')
textWidths = [];
totalTextWidth = 0;
main_link.each(function(){
textWidths.push($(this).width())
})
for (var i = 0; i < textWidths.length; i++) {
totalTextWidth += textWidths[i];
}
additionValues = (total_nav_width - totalTextWidth)/main_link.length;
main_link).each(function(){
intialWidth = $(this).width()
$(this).width( intialWidth + additionValues )
})
})

navigation bar entire width spaced items evenly

I'm a bit new to css. I'm trying to make a horizontal navigation bar with only 3 text items for mobile device viewing. I have width set to 100% and each section width set to 32% (I tried 33% but it would place the 3rd item on a new line.) It looks ok as it is, but when I hover (or click on using a mobile device) the background color changes and you can see the margins.
ul.nav {
width:100%;
margin:0 auto;
padding:0;
list-style:none;
display:inline-block;
background-color:#62564A;
text-align:center;
font-family: sans-serif;
}
.nav li {
display:inline;
}
.nav a {
width:33%;
text-align:center;
display:inline-block;
padding-bottom:13px;
padding-top:12px;
border-left: 1px solid #fff;
border-right: 1px solid #fff;
}
.nav a:hover {
background:#A26A42;
border:none;
width:32%
}
ul.nav li:first-child a{
border:none;
}
ul.nav li:last-child a {
border:none;
}
End of CSS
<ul class="nav">
<li>Search</li>
<li>Legend</li>
<li>Info</li>
</ul>
<div id="map_canvas" style="position:absolute;left:0;right:0;"></div>
Thank you for any help.
I'd rework your CSS like this jsFiddle example.
CSS
ul.nav {
width:100%;
margin:0 auto;
padding:0;
list-style:none;
background-color:#62564A;
text-align:center;
font-family: sans-serif;
}
.nav li {
display:inline-block;
width:33%;
margin:0;
padding:0;
}
.nav a {
text-align:center;
padding:12px 0 13px 0;
margin:0;
border-left: 1px solid #fff;
border-right: 1px solid #fff;
display:block;
}
.nav a:hover {
background:#A26A42;
border:none;
}
ul.nav li:first-child a{
border:none;
}
ul.nav li:last-child a {
border:none;
}​
Try this:
* { margin:0; padding:0; } // This reset should go at the top of your CSS (if you don't have one already)
.nav li {
display:block;
float:left;
width: 33%;
}
.nav li a {
display:block;
text-align: center;
}
Fiddle: http://jsfiddle.net/kboucher/duaa6/
On "hover" you make the menu items narrower than normal. Plus you remove ther border which will narrow it even more. Also, It looks like you are using a 1px border left and right for spacing. If this is the case use margin instead. Use jsfiddle to practice.
Try this:
ul.nav {
width:100%;
margin:0;
padding:0;
list-style:none;
text-align:center;
font-family: sans-serif;
}
.nav li {
display:inline;
}
.nav a {
width:32%;
text-align:center;
display:inline-block;
padding-bottom:13px;
padding-top:12px;
margin-left: 1px;
background: #62564A;
}
.nav a:hover {
background:#A26A42;
}
ul.nav li:first-child a{
margin-left: 0;
}
http://jsfiddle.net/mVv75/4/

DIV content overflows into footer, makes footer go upward on page

IM trying to get the div content not to flow past the footer, I want the content div to expand as the page expands, but when the text goes past the footer, it causes the footer to jump upward on the page
html, body {
margin:0; /top, right, bottom, left/
padding:0; /top, right, bottom, left/
height:100%;
}
container {
position:fixed;
top:0;
left:0;
width:100%;
margin: 0 auto -100px;
height: auto;
min-height:100%;
}
content {
position: relative;
padding-bottom:100px;
overflow:auto;
height:100%;
}
Header, #Footer {
position: absolute;
width:100%;
background:url('bglines.png');
background-size:15px 15px;
color:white;
padding:0 auto;
text-align:center;
color:#2FAACE;
}
Footer {
margin-top: 100px;
clear:both;
}
menu {
position:absolute;
list-style-type:none;
background: #808080;
width:100%;
padding: 85px 0px 0px 0px; /* Always on top */
}
ptop {
text-transform:uppercase;
font-family:impact;
font-size:40pt;
margin: 15px auto;
color:#2FAACE;
}
pbottom {
font-family:times;
font-size:14pt;
color:#2FAACE;
}
main {
position: absolute;
text-align:center;
left:50%;
width:90%;
margin-left: -45%;
top:150px;
color:white;
padding-bottom:100px;
}
p {
font-size: 75px;
color:white;
}
mainbg {
background:#CCCCCC;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
opacity:0.9;
filter:alpha(opacity=90); /* For IE8 and earlier */
left:50px;
width:95%;
top:150px;
position: absolute;
}
li {
line-height:40px;
margin:0px 0px 0px 0px;
padding:0px 5px 5px 0px;
text-align:center;
float:left;
}
a, a:hover {
display:block;
font-family:Georgia;
width: 75px;
text-decoration:none;
font-size:30px;
}
a { color:white; }
a:Hover {
background:#2FAACE;
border-radius:9px 9px 9px 9px;
color:#FFFFFF; /*TL, TR, BR, BL*/
}
Please add a div with clear:both before footer. It actually clears all floating which fixes the footer to stay at bottom.
<div style="clear:both;"></div>
OR if you have defined class (clear) in your style then
<div class="clear"></div>

Resources