navbar with submenu width impossible to get right - html

so I have made a navbar with an item that has a submenu.
<div id=menu>
<div class=optie>Nieuws</div>
<div class=optie>Acties</div>
<div class=optie>Over ons</div>
<div class=optie>Webshop</div>
<div class=optie>
Webshop
<span class=submenu>
<a class=suboptie href="#">Producten</a>
<a class=suboptie href="#">Winkelwagen</a>
<a class=suboptie href="#">Afrekenen</a>
</span>
</div>
</div>
The navbar works and it's fine however i can't get the submenu items to have the proper width.
The submenu is nested inside a head which allready has a dynamic size. Since I have to use position absolute it's nearly impossible to calculate the correct width. Is there a way to have the submenu automatically have the same width as the parent?
Here is a jsfiddle.
any help is appreciated
https://jsfiddle.net/eb8k0tbo/3/

The need to set position:relative on the parent and then width:100% on the child.
#menu {
font-size: 0px;
width: 80%;
text-align: center;
}
.optie {
display: inline-block;
font-size: 18px;
width: calc(20% - 2px);
height: 1.5em;
line-height: 1.5em;
background: linear-gradient(to bottom, #919191 0%,#303030 41%,#000000 75%,#000000 100%);
border: 1px solid grey;
color: white;
font-weight: bold;
position: relative;
}
.optie a {
color: white;
text-decoration: none;
}
.optie:hover a {
//color: rgb(56,56,56);
}
.optie:hover {
color: rgb(56,56,56);
background: linear-gradient(to bottom, #fac695 0%,#f4913a 58%,#f4913a 79%,#ed790e 100%);
}
.submenu {
display: none;
}
.optie:hover .submenu {
display: block;
position: absolute;
border: 1px solid grey;
width: 100%;;
}
.suboptie {
display: block;
background: linear-gradient(to bottom, #919191 0%,#303030 41%,#000000 75%,#000000 100%);
}
.submenu a:hover {
background: linear-gradient(to bottom, #fac695 0%,#f4913a 58%,#f4913a 79%,#ed790e 100%);
}
.submenu a {
color: white;
text-decoration: none;
}
.suboptie:hover {
color: rgb(56,56,56);
}
<div id=menu>
<div class=optie>Nieuws</div>
<div class=optie>Acties</div>
<div class=optie>Over ons</div>
<div class=optie>
Webshop
<span class=submenu>
<a class=suboptie href="#">Producten</a>
<a class=suboptie href="#">Winkelwagen</a>
<a class=suboptie href="#">Afrekenen</a>
</span>
</div>
</div>

Related

How add extra vertical spacing between dotteds using text-decoration-style: dotted;

There's a way to add some extra vertical spacing between dots using text-decoration-style: dotted;?
I have this anchor:
.anchor {
text-decoration: underline;
text-decoration-style: dotted;
text-underline-offset: 5px;
}
<a class="anchor" href="">
Hi! Click me
</a>
No there is not. You would have to use a pseudo-element with a radial gradient.
:root {
--gap: 4px;
--color: red;
--distance: -5px;
}
.anchor {
text-decoration: none;
position: relative;
display: inline-block;
margin: 2em;
}
.anchor:after {
content: "";
height: 5px;
width: 100%;
position: absolute;
bottom: var(--distance);
left: 0;
background-image: radial-gradient(circle, var(--color) 1px, transparent 1.5px);
background-repeat: repeat-x;
background-size: var(--gap) 4px;
}
.v2 {
--gap: 12px;
--color: green;
--distance: -10px;
}
<a class="anchor" href="">
Hi! Click me
</a>
<a class="anchor v2" href="">
Hi! Click me My gap is wider
</a>

how to make dropdown menu select the option you clicked on last time

as I said in the title I am trying to make my dropdown menu select the last option i clicked on for example:https://www.youtube.com/user/PewDiePie/videos?view=0&sort=dd&flow=grid
in some youtube channels if you select videos and click on SORT BY then choose any option then if you click on sort by again you will see the last option you clicked is selected
(css is internal) this is my code:
html:
<div style="display: inline-block; text-align: right; width: 89%"> <div tabindex="0" class="menu">
<div class="menu-dropdown">
Most Popular
Newest
Oldest
</div>
</div>
</div>
css:
<style>
/* style for the css menu dropdown container */
.menu {
position:relative;
display:inline-block;
z-index:2; padding:0;
margin:0;
outline:0;
text-align:left;
}
/* style for the button */
.menu:before {
content: "\2630 \a0 Menu";
color:white;
padding: 5px 10px;
border: 1px solid #555;
border-radius:3px;
background: #96305e;
background: -moz-linear-gradient(top, #96305e 0%, #822956 10%, #822956 90%, #751749 100%);
background: -webkit-linear-gradient(top, #96305e 0%,#822956 10%,#822956 90%,#751749 100%);
background: linear-gradient(to bottom, #96305e 0%,#822956 10%,#822956 90%,#751749 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#96305e',
endColorstr='#751749',GradientType=0 );
}
.menu:focus { pointer-events:none; }
/* If :focus detected the dropdown menu is displayed by making it visible */
.menu:focus .menu-dropdown { opacity:1; visibility:visible; }
/* style for the dropdown box */
.menu-dropdown {
background-color: #364656;
width: auto;
margin:3px 0 0 0;
padding: 10px;
border-radius:3px;
border:1px black solid;
border-radius:3px;
pointer-events: auto;
position: absolute;
z-index: 1;
opacity: 0;
visibility: hidden;
transition: visibility 1s;
background: #1f8bd3;
background: -moz-linear-gradient(top, #1f8bd3 0%, #1b7aba 10%, #1b7aba 90%, #1b61b7 100%);
background: -webkit-linear-gradient(top, #1f8bd3 0%,#1b7aba 10%,#1b7aba 90%,#1b61b7 100%);
background: linear-gradient(to bottom, #1f8bd3 0%,#1b7aba 10%,#1b7aba 90%,#1b61b7 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1f8bd3',
endColorstr='#1b61b7',GradientType=0 );
}
/* style the links in the dropdown */
.menu-dropdown a {
background:transparent;
border:none;
outline:0;
display:block;
color:white;
text-decoration:none;
width:160px;
padding:5px;
}
</style>
EDIT
Full Html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<div id="header">
<div class="container">
Home
<ul id="header-nav">
<li><a href="about.html" >About</a></li>
<li><a href="contact.html" >Contact</a></li>
<li>Download Links</li>
</ul>
</div>
</div>
<body>
<div style="display: inline-block; text-align: right; width: 89%">
<div tabindex="0" class="menu">
<div class="menu-dropdown">
Most Popular
Newest
Oldest
</div>
</div>
</div>
<style>
/* style for the css menu dropdown container */
.menu {
position:relative;
display:inline-block;
z-index:2; padding:0;
margin:0;
outline:0;
text-align:left;
}
/* style for the button */
.menu:before {
content: "\2630 \a0 Menu";
color:white;
padding: 5px 10px;
border: 1px solid #555;
border-radius:3px;
background: #96305e;
background: -moz-linear-gradient(top, #96305e 0%, #822956 10%, #822956
90%, #751749 100%);
background: -webkit-linear-gradient(top, #96305e 0%,#822956 10%,#822956
90%,#751749 100%);
background: linear-gradient(to bottom, #96305e 0%,#822956 10%,#822956
90%,#751749 100%);
filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr='#96305e', endColorstr='#751749',GradientType=0 );
}
.menu:focus { pointer-events:none; }
/* If :focus detected the dropdown menu is displayed by making it visible
*/
.menu:focus .menu-dropdown { opacity:1; visibility:visible; }
/* style for the dropdown box */
.menu-dropdown {
background-color: #364656;
width: auto;
margin:3px 0 0 0;
padding: 10px;
border-radius:3px;
border:1px black solid;
border-radius:3px;
pointer-events: auto;
position: absolute;
z-index: 1;
opacity: 0;
visibility: hidden;
transition: visibility 1s;
background: #1f8bd3;
background: -moz-linear-gradient(top, #1f8bd3 0%, #1b7aba 10%, #1b7aba
90%, #1b61b7 100%);
background: -webkit-linear-gradient(top, #1f8bd3 0%,#1b7aba 10%,#1b7aba
90%,#1b61b7 100%);
background: linear-gradient(to bottom, #1f8bd3 0%,#1b7aba 10%,#1b7aba
90%,#1b61b7 100%);
filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr='#1f8bd3', endColorstr='#1b61b7',GradientType=0 );
}
/* style the links in the dropdown */
.menu-dropdown a {
background:transparent;
border:none;
outline:0;
display:block;
color:white;
text-decoration:none;
width:160px;
padding:5px;
}
</style>
</body>
<center>
<h1>Games</h1>
<h3>
<a href="https://direct-link.net/165397/script"target="_blank" >Roblox
autorob script</a><br>
8 ball pool hack no root<br>
</h3>
</center>
<div id="footer">
<div class="container">
<div class="column">
<h4>My Links</h4>
<p>
<a href="https://web.facebook.com/YousefRaedXD"
target="_blank">Facebook</a><br>
<a href="https://www.youtube.com/channel/UC6x7kvBibYzem6i59UMc3kw"
target="_blank">Youtube</a>
</p>
</div>
<div class="column">
<h4>My Story</h4>
<p>Hi there! I study in middle school and i wish to be a web programmer
:3</p>
</div>
</div>
</div>
</html>
Full css (external):
#header-nav li {
display: inline;
padding-left: 20px;
}
#header-nav {
display: block;
float:right;
margin-top:0;
}
#header {
background-color: #1abc9c;
height: 150px;
line-height: 150px;
}
container {
max-width:1000px;
margin:0 auto;
}
#header-title {
display: block;
float: left;
font-size: 20px;
font-weight: bold;
}
#header a {
color: white;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 0.1em;
}
#header a:hover {
color: #222;
}
#footer {
background-color: #2f2f2f;
padding: 50px 0;
}
.column {
min-width: 300px
display: inline-block;
vertical-align: top;
}
#footer h4 {
color: white;
text-transform: uppercase;
letter-spacing: 0.1em
}
#footer p {
color:white;
}
a {
color: #1abc9c;
text-decoration: none;
}
a:hover {
color: #F6A623;
}
.post {
max-width: 800px;
margin: 0 auto;
padding: 60px 0;
}
.post-author img {
width: 50px;
height: 50px;
vertical-align: middle;
}
.post-author span {
margin-left: 16px;
}
.post-date {
color: D2D2D2;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 0.1em;
}
h1, h2, h3, h4 {
color: #333;
}
p {
line-height: 1.5;
}
#import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);
body {
margin: 0;
color: #555;
font-family: 'Montserrat', sans-serif;
}
.post, .about {
max-width: 800px;
margin: 0 auto;
padding: 60px 0;
}
Did you try to use a form in your menu and send by post or get (No matter which one) the last one you picked so, you'll be able to display it with a little bit of php.
<?php
echo"<button>{$_GET['lastOne']}</button>";
?>
!!! Only If I correctly understood the question !!!
What I understood is you want to add, like a history in your dropdown menu and the last button would be a link to the last one you visited
EDIT
Here is the code I told you I would make for you, prob not the best way to do it, but it's working
<div style="display: inline-block; text-align: right; width: 89%">
<div tabindex="0" class="menu">
<div class="menu-dropdown">
Most Popular
Newest
Oldest
<?php
if (isset($_GET['lastButtonClicked']))
{
$lastButtonClicked = $_GET['lastButtonClicked'];
echo"<a href='$lastButtonClicked'>Last button clicked</a>";
}
?>
</div>
</div>
</div>

how to make a div grow in width when the contents inside it are positioned absolute

I have a div inside which there is a text which has a subtitle that must always be positioned on the bottom right in this manner
I achieved this by making the parent div relative and the contents inside it as absolute.But the upper text can grow to whatever length and i want the parent div to expand with it and not overlay other elements which it is doing as shown in the image
Here is what i tried.
header {
height: 60px;
padding: 0 12px;
background: #fff;
position: fixed;
width: calc(100% - 24px);
z-index: 999999; // no z-index values above this for any body elements
box-shadow: 7px -9px 6px 6px $black;
left: 0;
li {
float: right;
display: block;
margin-left: 20px;
padding: 20px 0;
width: 18px;
text-align: right;
i {
color: $icon-grey;
font-size: $header-icon-size;
cursor: pointer;
&.fa-times {
color: $icon-red;
}
&.notify{
color: gold;
}
&.fa-caret-down{
color: gold;
}
}
img{
width: 40px;
height: 40px;
border-radius: 50%;
margin-top: -0.7em;
object-fit: cover;
object-position: center right;
}
}
.user-info {
text-align: right;
display: inline-block;
margin-top: -0.5em;
h5{
color: $section;
}
span{
color: $icon-grey;
font-size: 14px;
}
}
.user-details{
margin-right: 15px;
}
}
<header>
<li>
<i class="fas fa-caret-down"></i>
</li>
<li>
<img src="{{user.image}}">
</li>
<li>
<div class="user-info">
<h4>Smith</h4>
<p>CAD</p>
</div>
</li>
<li class="notification-menu">
<i class="fas fa-bell"></i>
</li>
</header>
All elements inside header are aligned on the right side.
I could not find any solution that just uses css.
Just use text-align:right...it seems to be adequate. No need for extra fancy layout options unless there is more to this than it appears.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
::before,
::after {
box-sizing: inherit;
}
.user-info {
text-align: right;
display: inline-block;
border: 1px solid grey;
}
<div class="user-info">
<h4>Smith</h4>
<p>CAD</p>
</div>
<div class="user-info">
<h4>Longer name - Smith</h4>
<p>CAD</p>
</div>
<div class="user-info">
<h4>Smith</h4>
<p>Longer Initials CAD</p>
</div>

I can't make two blocks in the same position level.

In this snippet, you can see the code.
I want to put mid_left and mid_right in the same div tag mid. but I can' position mid_right right, either out of the mid tag or not in the same level as mid_left. I tried float:left and display:inline-block, but none of them are working, how could I fix it?
/* CSS Document */
body {
margin:0 auto;
padding: 0;
background: url(../img/7_092641_2_meitu_1.jpg);
background-attachment: fixed;
background-repeat: no-repeat;
background-size: 100% 100%;
font-size: 15px;
color: #E2E2E2;
line-height: 24px;
font-family: '微软雅黑';
}
.logo {
width: 400px;
hight: 380px;
margin: -610px auto 0 -40px;
position:fixed;
}
.wrapper {
width: 1100px;
height: auto !important;
margin: 0 auto;
background-color:#F7F7F7;
}
.header {
width: 1050px;
height: 100px;
margin: 0 auto;
border: 1px;
/*background-image: url(../../../Stockholm-Sweden.jpg);*/
}
.header h1 {
font-size: 40px;
font-weight: 900;
font-family: '仿宋_GB2312';
margin: 0 auto;
padding-top: 18px;
}
/*------------------ NAV ------------------------*/
.container {
width: 1090px;
height:50x;
background : #464646;
background : -webkit-gradient(linear, left top, left bottom, from(rgb(168,168,168)), to(rgb(69,69,69)));
background : -moz-linear-gradient(top, rgb(168,168,168), rgb(69,69,69));
margin: 0 auto;
}
ul {
margin: 0;
padding: 0;
}
ul.menu {
height: 50px;
border-left: 1px solid rgba(0,0,0,0.3);
border-right: 1px solid rgba(255,255,255,0.3);
}
ul.menu li {
list-style: none;
float:left;
height: 49px;
text-align: center;
background: -webkit-gradient(radial, 50% 100%, 10, 50% 50%, 90, from(rgba(31,169,244,1)), to(rgba(0,28,78, 1)) );
background: -moz-radial-gradient(center 80px 45deg, circle cover, rgba(31,169,244,1) 0%, rgba(0,28,78, 1) 100%);
}
ul li a {
display: block;
padding: 0 20px;
border-left: 1px solid rgba(255,255,255,0.1);
border-right: 1px solid rgba(0,0,0,0.1);
text-align: center;
line-height: 49px;
font-size: medium;
font-weight: bold;
color: #FFF;
font-family: '微软雅黑';
text-decoration:none;
background : -webkit-gradient(linear, left top, left bottom, from(rgb(168,168,168)), to(rgb(69,69,69)));
background : -moz-linear-gradient(top, rgb(168,168,168), rgb(69,69,69));
-webkit-transition-property: background;
-webkit-transition-duration: 700ms;
-moz-transition-property: background;
-moz-transition-duration: 700ms;
}
ul li a:hover {
background: transparent none;
}
ul li.active a{
background: -webkit-gradient(radial, 50% 100%, 10, 50% 50%, 90, from(rgba(31,169,244,1)), to(rgba(0,28,78, 1)) );
background: -moz-radial-gradient(center 80px 45deg, circle cover, rgba(31,169,244,1) 0%, rgba(0,28,78, 1) 100%);
}
/*------------ slider ---------------*/
.slider_1 {
height: 400px;
width: 1090px;
margin: 20px auto 0 auto;
overflow: hidden;
}
/*----------- mid ------------------*/
.mid {
height:auto;
width:1000px;
margin:0 auto;
font-family:'仿宋_GB2312';
border: solid 1px #CCCCCC;
}
.mid a {
text-decoration: none;
}
.mid_span {
height:45px;
line-height:45px;
color:#004276;
font-size:18px;
font-weight:bold;
margin-right:6px;
}
.mid_left {
height: auto;
width: 490px;
margin: 0 auto 0 5px;
border-right: dashed #F2F2F2;
diaplay: inline-block;
}
.mid_right {
height: auto;
width: 480px;
margin: 0 10px 0 auto;
}
.mid_left_1 {
width: 100%;
height: auto;
margin: 0 auto;
}
.date {
color: #CECECE;
line-height:22px;
font-size: 12px;
}
.detail {
color:#BA2636;
}
.brif {
color:#454545;
line-height:22px;
margin-top: -5px;
}
.tittle {
height:80px;
width:1050px;
margin: 20px auto 10px auto;
text-align: center;
}
.tittle h2 {
font-family:'微软雅黑';
font-size: 24px;
font-weight: bold;
color: #292c2f;
display: inline-block;
}
.tittle_line{
background: url(../img/title_line.png) no-repeat;
width: 350px;
height: 8px;
margin: 0 10px 5px 10px;
display: inline-block;
}
footer {
width:1050px;
height:auto;
margin: 0 auto;
posion: absolute;
}
.footer-distributed{
background-color: #292c2f;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
box-sizing: border-box;
width: 100%;
text-align: left;
font: bold 16px sans-serif;
padding: 10px 25px 5px 25px;
margin-top: 80px;
}
.footer-distributed .footer-left,
.footer-distributed .footer-center,
.footer-distributed .footer-right{
display: inline-block;
vertical-align: top;
}
/* Footer left */
.footer-distributed .footer-left{
width: 40%;
margin-left: 40px;
}
/* The company logo */
.footer-distributed h3{
color: #ffffff;
font: normal 36px 'Cookie', cursive;
margin: 0;
}
.footer-distributed h3 span{
color: #5383d3;
}
/* Footer links */
.footer-distributed .footer-links{
color: #ffffff;
margin: 20px 0 12px;
padding: 0;
}
.footer-distributed .footer-links a{
display:inline-block;
line-height: 1.8;
text-decoration: none;
color: inherit;
}
.footer-distributed .footer-company-name{
color: #8f9296;
font-size: 14px;
font-weight: normal;
margin: 0;
}
/* Footer Center */
.footer-distributed .footer-center{
width: 35%;
}
.footer-distributed .footer-center i{
background-color: #33383b;
color: #ffffff;
font-size: 25px;
width: 38px;
height: 38px;
border-radius: 50%;
text-align: center;
line-height: 42px;
margin: 10px 15px;
vertical-align: middle;
}
.footer-distributed .footer-center i.fa-envelope{
font-size: 17px;
line-height: 38px;
}
.footer-distributed .footer-center p{
display: inline-block;
color: #ffffff;
vertical-align: middle;
margin:0;
}
.footer-distributed .footer-center p span{
display:block;
font-weight: normal;
font-size:14px;
line-height:2;
}
.footer-distributed .footer-center p a{
color: #5383d3;
text-decoration: none;;
}
/* Footer Right */
.footer-distributed .footer-right{
width: 20%;
}
.footer-distributed .footer-icons{
margin-top: 25px;
}
.footer-distributed .footer-icons a{
display: inline-block;
width: 35px;
height: 35px;
cursor: pointer;
background-color: #33383b;
border-radius: 2px;
font-size: 20px;
color: #ffffff;
text-align: center;
line-height: 35px;
margin-right: 12px;
margin-bottom: 5px;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>旅游导航</title>
<meta name="description" content="北欧旅游" />
<meta name="keywords" content="各种索引条目" />
<link href="css/style.css" rel="stylesheet" type="text/css">
<link href="css/pgwslider.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext,cyrillic' rel='stylesheet' type='text/css'>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</head>
<body>
<div class="wrapper">
<div class="header">
<h1>Header</h1>
</div><!-- header -->
<div class="container">
<ul class="menu">
<li>HOME</li>
<li>ABOUT</li>
<li>HOME</li>
<li>HOME</li>
<li>HOME</li>
<li>HOME</li>
</ul>
</div><!--navigation -->
<div class="tittle">
<div class="tittle_line"></div>
<h2>EXAMPLE</h2><div class="tittle_line"></div>
</div><!-- tittle -->
<div class="mid">
<div class="mid_left">
<div class="mid_left_1">
<a target="_blank" href="#" title="投资移民瑞典能享受欧盟待遇吗?" class="mid_span">投资移民瑞典能享受欧盟待遇吗?</a>
<span class="date">(02/11 14:50)</span> <br>
<p class="brif">投资移民瑞典能享受欧盟待遇吗?获得欧盟成员国的国籍,也意味着被整个欧盟接纳,直接成为欧盟公民,享受整个欧盟范围内的各种优待,包括经商,接受教育,找工作,都能够享受欧盟优先的原则。...<span class="detail">[</span>详细<span class="detail">]</span></p>
</div><!--med left 1 -->
<div class="mid_left_1">
<a target="_blank" href="#" title="一步到位获得瑞典移民身份享福利" class="mid_span">一步到位获得瑞典移民身份享福利</a>
<span class="date">(02/11 14:50)</span> <br>
<p class="brif">一步到位获得瑞典移民身份享福利。瑞典移民者在获得身份的同时,就能即刻享受福利,而一些国家规定则没有这么宽松,比如澳洲商业移民,在获得4年期的临时商务签证的期间,必须成功经营企业才能进一步申请转为移民,而...<span class="detail">[</span>详细<span class="detail">]</span></p>
</div><!--med left 1 -->
<div class="mid_left_1">
<a target="_blank" href="#" title="瑞典移民福利“一辈子都很幸福”" class="mid_span">瑞典移民福利“一辈子都很幸福”</a>
<span class="date">(02/11 14:50)</span> <br>
<p class="brif">瑞典移民申请材料有哪些,如果您计划到瑞典与您的丈夫、妻子、同居伴侣或者您的孩子或者其他近亲属长期居住,那么就应当了解申请居留许可之前要准备哪些申请材料。...<span class="detail">[</span>详细<span class="detail">]</span></p>
</div><!--med left 1 -->
<div class="mid_left_1">
<a target="_blank" href="#" title="欧洲各国移民福利大比拼 " class="mid_span">欧洲各国移民福利大比拼 </a>
<span class="date">(02/11 14:50)</span> <br>
<p class="brif">欧洲各国移民福利大比拼。2015年,欧洲移民政策将更加成熟稳定,也将受到市场更广泛的认可。下面就随小编来看看欧洲各国移民福利吧!看看有没有适合您的那一款。...<span class="detail">[</span>详细<span class="detail">]</span></p>
</div><!--med left 1 -->
</div><!--mid left -->
<div class="mid_right">
23t2erse452
</div>
</div><!--mid-->
<footer class="footer-distributed"><!--footer-->
<div class="footer-left">
<h3>Feito<span>AB</span></h3>
<p class="footer-company-name">Feito AB © 2015</p>
</div>
<div class="footer-center">
<div>
<i class="fa fa-map-marker"></i>
<p><span>Mejerigatan 29</span> Göteborg</p>
</div>
<div>
<i class="fa fa-phone"></i>
<p>+1 555 123456</p>
</div>
</div>
<!--
<div class="footer-right">
<div>
<i class="fa fa-envelope"></i>
<p>support#company.com</p>
</div>
</div>
-->
<div class="footer-right">
<div class="footer-icons">
<a href="#">
<img src="img/footer/1.jpg" alt="facebook">
</a>
<img src="img/footer/2.jpg" alt="facebook">
<img src="img/footer/3.jpg" alt="linkedin">
<img src="img/footer/4.jpg" alt="mewo">
</div>
</div>
</footer><!--footer-->
</div><!--wrapper-->
</body>
</html>
set .mid position to relative, and mid_left and mid_right position to absolute. Then mid_left and mid_right will stack on top of each other, with mid_right being on top since it appears later in the HTML.
Make sure you understand how the box model works.
http://www.w3schools.com/css/css_boxmodel.asp
When you add attributes like border and padding, it effectively adds to the width of your box.
So, having a container div with 1000px, you need to make sure of 2 things:
If you want to have 2 divs inside that container with 500px width (one left, one right) ensure that your width + border + padding does not exceed the 500px limit.
When using inline-blocks, there might be the scenario where a white space renders between your two blocks, effectively pushing the 2nd one right by a few pixels. If you have control over the HTML, make sure no white spaces exist between your left and right div. If you cannot control this, you can give the containing element font-size: 0px; and then just reset your font size inside the left and right elements (for instance 16px).
adding display: inline-block; for both .mid_left and .mid_right classes works perfectly for me. Also check, if you didn't have space between these two divs.
To use your current code, make these adjustments:
Correct the spelling of display from diaplay:
.mid_left {
display: inline-block;
}
And then add display: inline-block; to .mid_right.
Here is an example: JSFiddle.
Hope this solves your issue.
you have a couple of options
flexbox . depending on browser support . if you have IE10+ then this is the way to go
display: table on parent and display: table-cell on left/right container
keep the container with the biggest height in the page flow and position: absolute the second container . then add height: 100% on the positioned container

Menu out of right boundary but not left

So I have a navigation menu. nav.png is empty space and nav1.png nav2.png nav3.png nav4.png are actual buttons like home,about us, etc.
I have the following code:
#navigation_bar {
display: table;
margin: 0 auto;
}
.menu_btn {
display: table-cell;
}
.menu_btn img {
height: 90%;
}
<div id="navigation_bar">
<div class="menu_btn">
<img src="http://i.stack.imgur.com/7q5bs.png">
</div>
<div class="menu_btn">
<img src="http://i.stack.imgur.com/wxDQj.png">
</div>
<div class="menu_btn">
<img src="http://i.stack.imgur.com/Fwmkn.png">
</div>
<div class="menu_btn">
<img src="http://i.stack.imgur.com/qRpbK.png">
</div>
<div class="menu_btn">
<img src="http://i.stack.imgur.com/GksMc.png">
</div>
<div class="menu_btn">
<img src="http://i.stack.imgur.com/7q5bs.png">
</div>
</div>
With the above code I get this
As you see the menu ISN'T centered. I want the menu to be in the centre. the bar goes out of window on the right side. but on the left side it maintains a margin of few pixels...
I want it to go out of window on BOTH sides so it kind of appears as a black line throughout the page.
Also, my nav.png is a long image (width-wise).
here are the pngs
Take the background-image approach.
#navigation_bar {
background-image: url(http://i.stack.imgur.com/7q5bs.png);
background-repeat: repeat-x;
text-align:center;
}
.menu_btn {
display:inline-block;
}
.menu_btn img {
height: 90%;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GETTING STARTED WITH BRACKETS</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="content">
<img src="images/logo/logo.png">
</div>
<hr>
<div id="navigation_bar">
<div class="menu_btn"><img src="http://i.stack.imgur.com/wxDQj.png" /></div>
<div class="menu_btn"><img src="http://i.stack.imgur.com/Fwmkn.png" /></div>
<div class="menu_btn"><img src="http://i.stack.imgur.com/qRpbK.png" /></div>
<div class="menu_btn"><img src="http://i.stack.imgur.com/GksMc.png" /></div>
</div>
<hr>
</body>
</html>
Let's modernise!
Let's make this with pure CSS:
Background CSS gradients and no images, mirrored using pseudo elements
We can achieve this even more easily by using a linear gradient background and no images at all.
The background is created by the linear-gradient.
The font can be changed in the CSS if desired.
The text is vertically centered with the line-height: 40px (matching the height of the nav)
The text is horizontally centered with text-align: center on the nav
Using the data-* and pseudo elements, we can even provide a mirror image underneath with pure CSS.
Main benefits:
Link text is easily archived by search engines, improving SEO and link text is easily read by screen-readers
Gradient and links can easily be changed without editing images
Complete Example
CSS gradients are supported IE10 + and IE 6 - 9 are supported using a filter. Ensure that there are no gaps between the opening and closing <a>. This prevents an inline gap.
nav {
height: 40px;
background: #000;/*Non supporting browsers*/
background: linear-gradient(to bottom, rgba(76, 76, 76, 1) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);/*CSS Standard*/
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=0 ); /*IE6 - 9*/
line-height: 40px;
text-transform: uppercase;
text-align: center;
min-width: 620px;
position: relative;
}
nav::before {
background: linear-gradient(to top, rgba(76, 76, 76, 0) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);/*CSS Standard*/
content: '';
display: block;
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 100%;
opacity: 0.2;
}
nav a {
color: #FFF;
text-decoration: none;
font-weight: bold;
font-size: 1.2em;
border-right: solid 1px #FFF;
padding: 0 10px;
position: relative;
display: inline-block;
}
nav a:first-child {
border-left: solid 1px #FFF;
}
nav a:hover {
background: #F00;
background: linear-gradient(to bottom, rgba(248,80,50,1) 0%,rgba(241,111,92,1) 50%,rgba(246,41,12,1) 51%,rgba(240,47,23,1) 71%,rgba(231,56,39,1) 100%);
}
nav a::before {
content: attr(data-mirror);
position: absolute;
top: 100%;
left: 0;
padding: 0 10px;
color: #000;
transform: scaleY(-1);
color: #FFF;
opacity: 0.2;
pointer-events: none;
}
nav a:hover::before {
background: rgba(255,255,255,0.2);
opacity: 0.5;
}
<nav>
HomeCategoriesCreateUpload
</nav>