Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
I'm trying to aling items in the same row.
I would to obtain the button in the center and the legend in the right part ( near the end of the page)
.legendContainer {
// padding: 10px
// display: flex;
align-content: flex-end;
justify-content: flex-end;
// margin-left: 10px;
}
.legend {
list-style: none;
}
.legend li {
float: left;
margin-right: 10px;
}
.legend span {
border: 1px solid #ccc;
float: left;
width: 12px;
height: 12px;
margin: 2px;
margin-right: 5px;
}
.legendTitle {
font-weight: bold;
}
.legend .KO {
background-color: #FFA8A8;
}
.legend .aOK {
background-color: #B6FFCE;
}
.legend .send {
background-color: #F6FFA4;
}
<div class="row justify-content-center ">
<div class="col-md-4"></div>
<div class="col-md-4" style="padding-left: 70px;">
<button>Offers</button>
<button>Opportunity</button>
</div>
<div class="col-md-4" style="padding-left: 140px">
<div class="legendContainer" *ngIf="tableOffer">
<ul class="legend">
<div class="legendTitle">Legend</div>
<li><span class="KO"></span> KO</li><br>
<li><span class="Send"></span>Send</li><br>
<li><span class="OK"></span> OK</li>
</ul>
</div>
</div>
</div>
I have tried using padding but on mobile device it isn't look good.
Something like this?
Removed the big style paddings: style="padding-left: 70px;", style="padding-left: 140px" from the divs. div.row first child and .legendcontainer with width: fit-content; to fit their content and margin-left: auto, (.ms-auto) so they move to the end. Changed the .col of the buttons div to col-8 (60% big) and the legend container to col-4 (40% big). Bootstrap max col size (and default if its not defined) is 12 (8+4).
.legendContainer {
width: fit-content;
margin-left: auto;
}
.legend {
list-style: none;
margin: 0;
}
.legend li {
float: left;
}
.legend span {
border: 1px solid #ccc;
float: left;
width: 12px;
height: 12px;
margin: 2px;
margin-right: 5px;
}
.legendTitle {
font-weight: bold;
}
.legend .KO {
background-color: #FFA8A8;
}
.legend .aOK {
background-color: #B6FFCE;
}
.legend .send {
background-color: #F6FFA4;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row flex-row justify-content-center w-100 align-items-center">
<div class="col-8 ms-auto p-0" style="width:fit-content;">
<button>Offers</button>
<button>Opportunity</button>
</div>
<div class="col-4">
<div class="legendContainer" *ngIf="tableOffer">
<ul class="legend">
<div class="legendTitle">Legend</div>
<li><span class="KO"></span> KO</li><br>
<li><span class="Send"></span>Send</li><br>
<li><span class="OK"></span> OK</li>
</ul>
</div>
</div>
</div>
Buttons in the center. And the legend on the right.
.btns {
text-align: center;
}
.legendContainer {
/*padding: 10px*/
display: flex;
align-content: center;
justify-content: flex-end;;
/*margin-left: 10px;*/
xbackground: gray;
}
.legendContainer ul {
margin-top: 2px;
}
.legend {
list-style: none;
}
.legend li {
float: left;
margin-right: 10px;
}
.legend span {
border: 1px solid #ccc;
float: left;
width: 12px;
height: 12px;
margin: 2px;
margin-right: 5px;
}
.legendTitle {
font-weight: bold;
}
.legend .KO {
background-color: #FFA8A8;
}
.legend .aOK {
background-color: #B6FFCE;
}
.legend .send {
background-color: #F6FFA4;
}
<div class="row justify-content-center ">
<div class="col-md-4"></div>
<div class="col-md-4 btns" style="">
<button>Offers</button>
<button>Opportunity</button>
</div>
<div class="col-md-4" style="padding-left: 140px">
<div class="legendContainer" *ngIf="tableOffer">
<ul class="legend">
<div class="legendTitle">Legend</div>
<li><span class="KO"></span> KO</li><br>
<li><span class="Send"></span>Send</li><br>
<li><span class="OK"></span> OK</li>
</ul>
</div>
</div>
</div>
legend to display: inline;, or float the li left or right. Additionally, you can also use display:flex; on the ul
.legendContainer {
}
.legend {
display: flex;
justify-content:space-around;
list-style-type:none;
float: left;
}
.legend li {
/* float: left; */
margin-right: 10px;
}
.legend span {
border: 1px solid #ccc;
float: left;
width: 12px;
height: 12px;
margin: 2px;
margin-right: 5px;
}
.legendTitle {
font-weight: bold;
}
.legend .KO {
background-color: #FFA8A8;
}
.legend .aOK {
background-color: #B6FFCE;
}
.legend .send {
background-color: #F6FFA4;
}
<div class="row justify-content-center ">
<div class="col-md-4"></div>
<div class="col-md-4" style="padding-left: 70px;">
<button>Offers</button>
<button>Opportunity</button>
</div>
<div class="col-md-4" style="padding-left: 140px">
<div class="legendContainer" *ngIf="tableOffer">
<ul class="legend">
<div class="legendTitle">Legend</div>
<li><span class="KO"></span> KO</li><br>
<li><span class="Send"></span>Send</li><br>
<li><span class="OK"></span> OK</li>
</ul>
</div>
</div>
</div>
Related
I know this has been asked in this forum many times, but I read every topic about it and tried many suggested solutions and still, I'm not able to make it work for my own case.
Here's this case. I have this grid of content cards, but depending on the length of the content or whether or not every element in the card is used, the card has a different height. So, elements are not aligned from one card to another. I'd like to edit my code so the top of each element starts at a relative height so they are aligned.
Codepen: https://codepen.io/louischausse/pen/VRQxgB
I'd like that top of each child div align with each other
Thanks for your help
.section__etudes-card > span, [gr-grid~=row--block], .section__featured-article .hs_cos_wrapper .widget-module ul {
position: relative;
display: -ms-flexbox;
-js-display: flex;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-left: -15px;
margin-right: -15px;
align-items: stretch;}
.section__etudes-card > span > div, [gr-grid=block], .section__featured-article .hs_cos_wrapper .widget-module ul li {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
max-width: 100%;
padding-left: 15px;
padding-right: 15px;
margin-top: 30px; }
.section__etudes-card {
margin-top: 1.875rem;
margin-bottom: 1.875rem; }
.section__etudes-card > span > div {
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%; }
#media (min-width: 48em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 33%;
flex-basis: 33%;
max-width: 33%; } }
#media (min-width: 64em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
max-width: 25%; } }
.section__etudes-card > span > div:empty {
display: none; }
.etude-card {
display: block;
text-align: center;
margin-bottom: 0.9375rem;
text-decoration: none; }
#media (min-width: 64em) {
.etude-card:hover [class*="btn--"] {
/*transform: scale(1.05);*/
color: #fff;
background-color: #e98815;
border-color: #e98815; } }
.etude-card .etude-card__title {
margin-top: 0.9375rem;
margin-bottom: 0.9375rem;
font-weight: bold;
color: #333333;
line-height: 1.1; }
.etude-card .etude-card__date {
font-size: 0.8125em;
margin-top: 0.625rem;
margin-bottom: 0.625rem; }
.etude-card .etude-card__ufc {
color: #FFFFFF;
font-size: .75em;
padding: 3px 8px;
background-color: #e98815;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card .etude-card__cost {
color: #e98815;
font-size: .75em;
padding: 3px 8px;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card [class*="btn--"] {
padding-left: .5em;
padding-right: .5em;
text-transform: none; }
.etude-card img {
width: 100%;
max-width: 215px;
margin-left: auto;
margin-right: auto; }
.etude-card__ufc:empty {
display: none; }
.etude-card__cost:empty {
display: none; }
.btn--primary {
padding: 10px 35px;
font-size: 16px;
border-radius: 5px;
display: inline-block;
position: relative;
z-index: 0;
text-decoration: none;
text-transform: none !important;
color: #FFFFFF;
background-color: #e98815;
border: 2px solid transparent;
}
.btn--primary:hover {
background: #ffffff !important;
color: #e98815 !important;
border: 2px solid #e98815 !important;
}
<section class="section__etudes-card">
<span id="hs_cos_wrapper_Ressource_center_element" class="hs_cos_wrapper hs_cos_wrapper_widget_container hs_cos_wrapper_type_widget_container" style="" data-hs-cos-general-type="widget_container" data-hs-cos-type="widget_container"><div id="hs_cos_wrapper_widget_1552502647360" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1552496573108" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS A VERY MUCH LONGER EVENT TITLE CAUSING PROBLEMS
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1551887999614" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888011972" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888047237" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
</section>
Is here what you want :
All the events title aligned
All the tag aligned
The button always at the bottom
What you will need
All the card having the same height
The card being a flex column
For mor clarity, I'll add the necessary css at the end of your css.
.section__etudes-card > span > div {
display: flex; /* Necessary for the cards to have the same height */
}
.etude-card {
display: flex; /* Necessary for the cards to have the same height */
flex-direction: column; /* To be able to push the childrens down */
width: 100%;
}
.etude-card > :nth-child(3) {
margin-top: auto; /* Will push the first tag down */
}
.etude-card__date:nth-last-child(3) {
margin-top: auto; /* Will push everything starting with the date down */
}
.section__etudes-card > span, [gr-grid~=row--block], .section__featured-article .hs_cos_wrapper .widget-module ul {
position: relative;
display: -ms-flexbox;
-js-display: flex;
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-left: -15px;
margin-right: -15px;
align-items: stretch;}
.section__etudes-card > span > div, [gr-grid=block], .section__featured-article .hs_cos_wrapper .widget-module ul li {
-ms-flex: 1 1 auto;
flex: 1 1 auto;
-ms-flex-preferred-size: 100%;
flex-basis: 100%;
max-width: 100%;
padding-left: 15px;
padding-right: 15px;
margin-top: 30px; }
.section__etudes-card {
margin-top: 1.875rem;
margin-bottom: 1.875rem; }
.section__etudes-card > span > div {
-ms-flex-preferred-size: 50%;
flex-basis: 50%;
max-width: 50%; }
#media (min-width: 48em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 33%;
flex-basis: 33%;
max-width: 33%; } }
#media (min-width: 64em) {
.section__etudes-card > span > div {
-ms-flex-preferred-size: 25%;
flex-basis: 25%;
max-width: 25%; } }
.section__etudes-card > span > div:empty {
display: none; }
.etude-card {
display: block;
text-align: center;
margin-bottom: 0.9375rem;
text-decoration: none; }
#media (min-width: 64em) {
.etude-card:hover [class*="btn--"] {
/*transform: scale(1.05);*/
color: #fff;
background-color: #e98815;
border-color: #e98815; } }
.etude-card .etude-card__title {
margin-top: 0.9375rem;
margin-bottom: 0.9375rem;
font-weight: bold;
color: #333333;
line-height: 1.1; }
.etude-card .etude-card__date {
font-size: 0.8125em;
margin-top: 0.625rem;
margin-bottom: 0.625rem; }
.etude-card .etude-card__ufc {
color: #FFFFFF;
font-size: .75em;
padding: 3px 8px;
background-color: #e98815;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card .etude-card__cost {
color: #e98815;
font-size: .75em;
padding: 3px 8px;
width: 75px;
margin: 0 auto;
border: 1px solid #e98815;}
.etude-card [class*="btn--"] {
padding-left: .5em;
padding-right: .5em;
text-transform: none; }
.etude-card img {
width: 100%;
max-width: 215px;
margin-left: auto;
margin-right: auto; }
.etude-card__ufc:empty {
display: none; }
.etude-card__cost:empty {
display: none; }
.btn--primary {
padding: 10px 35px;
font-size: 16px;
border-radius: 5px;
display: inline-block;
position: relative;
z-index: 0;
text-decoration: none;
text-transform: none !important;
color: #FFFFFF;
background-color: #e98815;
border: 2px solid transparent;
}
.btn--primary:hover {
background: #ffffff !important;
color: #e98815 !important;
border: 2px solid #e98815 !important;
}
/* The changes: */
.section__etudes-card > span > div {
display: flex;
}
.etude-card {
display: flex;
flex-direction: column;
width: 100%;
}
.etude-card > :nth-child(3) {
margin-top: auto;
}
.etude-card__date:nth-last-child(3) {
margin-top: auto;
}
<section class="section__etudes-card">
<span id="hs_cos_wrapper_Ressource_center_element" class="hs_cos_wrapper hs_cos_wrapper_widget_container hs_cos_wrapper_type_widget_container" style="" data-hs-cos-general-type="widget_container" data-hs-cos-type="widget_container"><div id="hs_cos_wrapper_widget_1552502647360" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1552496573108" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS A VERY MUCH LONGER EVENT TITLE CAUSING PROBLEMS
</div>
<div class="etude-card__ufc">TAG 1</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
<div id="hs_cos_wrapper_widget_1551887999614" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888011972" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module"><!-- custom widget definition not found --></div>
<div id="hs_cos_wrapper_widget_1551888047237" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_module" style="" data-hs-cos-general-type="widget" data-hs-cos-type="module">
<a href="https://codepen.io/" class="etude-card">
<img src="https://i.ibb.co/34S4L8B/image-placeholder.jpg" alt="image-placeholder"/>
<div class="etude-card__title">
THIS IS EVENT TITLE
</div>
<div class="etude-card__cost">TAG 2</div>
<div class="etude-card__date">
Place
</div>
<div class="etude-card__date">
Time
</div>
<span class="btn--primary">
See details
</span>
</a>
</div>
</section>
This question already has answers here:
Flexbox, z-index & position: static: Why isn't it working?
(1 answer)
Understanding z-index stacking order
(1 answer)
Closed 5 years ago.
I'm trying to have two columns, one being a menu which can expand and overlap the other column. But I used a flex element to wrap these columns and my menu expands behind the other element, even with a greater z-index.
The render is something like this:
.main {
font-family: 'Open Sans', Helvetica, sans-serif;
display: flex;
background-color: #99baef;
}
nav {
height: 100%;
width: 8em;
background-color: black;
z-index: 1;
}
.navbox {
box-sizing: border-box;
background-color: black;
color: white;
height: 4em;
width: 100%;
text-align: center;
line-height: 4em;
border-top: 1px dotted #99baef;
transition: all 1s;
}
.navbox:hover {
width: 130%;
border-top: none;
background-color: #4a77c4;
color: black;
}
.container {
padding: 1em;
}
a {text-decoration: inherit;}
<div class="main">
<div class="maincolumn">
<nav>
<a href="">
<div class="navbox">
Nav 1
</div>
</a>
<a href="">
<div class="navbox">
Nav 2
</div>
</a>
</nav>
</div>
<div class="maincolumn">
<div class="container">
<h2>Title</h2>
<p>This is a text.</p>
</div>
</div>
</div>
See? I want my menu to overlap the rest of my page when expanding. How can I do that?
The z-index property only effects elements that have a position value other than static (the default) or are flex items (direct children of display: flex or display: inline-flex).
There are two options to make the z-index work in your case:
Set the z-index to the 1st .maincolumn, which is a flexbox item:
.maincolumn:first-child {
z-index: 1;
}
.main {
font-family: 'Open Sans', Helvetica, sans-serif;
display: flex;
background-color: #99baef;
}
.maincolumn:first-child {
z-index: 1;
}
nav {
height: 100%;
width: 8em;
background-color: black;
}
.navbox {
box-sizing: border-box;
background-color: black;
color: white;
height: 4em;
width: 100%;
text-align: center;
line-height: 4em;
border-top: 1px dotted #99baef;
transition: all 1s;
}
.navbox:hover {
width: 130%;
border-top: none;
background-color: #4a77c4;
color: black;
}
.container {
padding: 1em;
}
a {text-decoration: inherit;}
<div class="main">
<div class="maincolumn">
<nav>
<a href="">
<div class="navbox">
Nav 1
</div>
</a>
<a href="">
<div class="navbox">
Nav 2
</div>
</a>
</nav>
</div>
<div class="maincolumn">
<div class="container">
<h2>Titre</h2>
<p>This is a text.</p>
</div>
</div>
</div>
or
Set position: relative to nav:
nav {
position: relative;
height: 100%;
width: 8em;
background-color: black;
z-index: 1;
}
.main {
font-family: 'Open Sans', Helvetica, sans-serif;
display: flex;
background-color: #99baef;
}
nav {
position: relative;
height: 100%;
width: 8em;
background-color: black;
z-index: 1;
}
.navbox {
box-sizing: border-box;
background-color: black;
color: white;
height: 4em;
width: 100%;
text-align: center;
line-height: 4em;
border-top: 1px dotted #99baef;
transition: all 1s;
}
.navbox:hover {
width: 130%;
border-top: none;
background-color: #4a77c4;
color: black;
}
.container {
padding: 1em;
}
a {text-decoration: inherit;}
<div class="main">
<div class="maincolumn">
<nav>
<a href="">
<div class="navbox">
Nav 1
</div>
</a>
<a href="">
<div class="navbox">
Nav 2
</div>
</a>
</nav>
</div>
<div class="maincolumn">
<div class="container">
<h2>Titre</h2>
<p>This is a text.</p>
</div>
</div>
</div>
Flex items are only direct children of flex-container.
Flex items respect z-index order, but you are applying z-index not to flex-items but to their descendants.
From w3c flexbox spec:
Flex items paint exactly the same as inline blocks CSS21, except that order-modified document order is used in place of raw document order, and z-index values other than auto create a stacking context even if position is static.
So for this to work you should apply greater z-index to your first flex item. Demo:
.main {
font-family: 'Open Sans', Helvetica, sans-serif;
display: flex;
background-color: #99baef;
}
.maincolumn:first-child {
z-index: 1;
}
nav {
height: 100%;
width: 8em;
background-color: black;
}
.navbox {
box-sizing: border-box;
background-color: black;
color: white;
height: 4em;
width: 100%;
text-align: center;
line-height: 4em;
border-top: 1px dotted #99baef;
transition: all 1s;
}
.navbox:hover {
width: 130%;
border-top: none;
background-color: #4a77c4;
color: black;
}
.container {
padding: 1em;
}
a {text-decoration: inherit;}
<div class="main">
<div class="maincolumn">
<nav>
<a href="">
<div class="navbox">
Nav 1
</div>
</a>
<a href="">
<div class="navbox">
Nav 2
</div>
</a>
</nav>
</div>
<div class="maincolumn">
<div class="container">
<h2>Title</h2>
<p>This is a text.</p>
</div>
</div>
</div>
I was wondering if is it possible to create a submenu using divs? All online tutorials use this ul li thing. I don't know how to activate my submenu by hovering over an option. Should I add new class to "director" div? Incuding photos and code pieces.
HTML:
.menu_opcje {
float: left;
min-width: 100px;
text-align: center;
border-right: dotted 2px black;
padding: 10px;
}
.menu_wysuwane {
min-width: 100px;
text-align: center;
border-bottom: dotted 2px black;
padding: 10px;
display: none;
}
.menu_wysuwane:hover {
background-color: white;
}
.menu_opcje:hover,
.sidebar_opcje:hover {
background-color: lightgray;
cursor: pointer;
}
<div id="menu">
<div class="menu_opcje">Strona główna</div>
<div class="menu_opcje">Galeria</div>
<div class="menu_opcje">Reżyserzy
<div>
<div class="menu_wysuwane">Quentin Tarantino</div>
<div class="menu_wysuwane">Bracia Coen</div>
<div class="menu_wysuwane">Wes Anderson</div>
</div>
</div>
</div>
https://i.stack.imgur.com/cldDy.png
https://i.stack.imgur.com/TrvsC.png
It is semantically incorrect, though making it appear on hover, do like this
.menu_opcje:hover div {
display: block;
}
Sample snippet
.menu_opcje {
float: left;
min-width: 100px;
text-align: center;
border-right: dotted 2px black;
padding: 10px;
}
.menu_wysuwane {
min-width: 100px;
text-align: center;
border-bottom: dotted 2px black;
padding: 10px;
display: none;
}
.menu_wysuwane:hover {
background-color: white;
}
.menu_opcje:hover,
.sidebar_opcje:hover {
background-color: lightgray;
cursor: pointer;
}
.menu_opcje:hover div {
display: block;
}
<div id="menu">
<div class="menu_opcje">Strona główna</div>
<div class="menu_opcje">Galeria</div>
<div class="menu_opcje">Reżyserzy
<div>
<div class="menu_wysuwane">Quentin Tarantino</div>
<div class="menu_wysuwane">Bracia Coen</div>
<div class="menu_wysuwane">Wes Anderson</div>
</div>
</div>
</div>
This is my image-button for my website. http://puu.sh/cK7Sf/6309c39cdb.jpg When I re-size my browser it goes over here http://puu.sh/cK7VU/f17dafcc41.jpg
Here is my code
HTML
<div class="Nav">
<div id="buttons">
<div id="home_button"></div>
CSS
#home_button {
background-image: url("home.png");
background-repeat:no-repeat;
background-size: 100%;
width: 150px;
height: 60px;
position: absolute;
top: 196px;
left: 502px;
z-index: 10;
}
I am new to web developing so please don't hate :)
I've created an example to show you what a basic nav bar styling looks like.
Demo on dabblet
HTML:
<body>
<!--Navigation-Bar-Container-->
<div class="nav-container">
<!--Navigation-Bar-Item-Wrapper-->
<div class="nav">
<!--Items-->
<div id="menu-item-1" class="menu-item">Item 1</div>
<div id="menu-item-2" class="menu-item">Item 2</div>
<div id="menu-item-3" class="menu-item">Item 3</div>
<div id="menu-item-4" class="menu-item">Item 4</div>
<div id="menu-item-5" class="menu-item">Item 5</div>
<hr />
</div>
</div>
<!--Content-->
</body>
CSS:
body {
background: url(http://s25.postimg.org/b6q25p4p7/black_thread.png) repeat black;
}
hr {
color: #777777;
}
.nav-container {
top: 20px;
position: relative;
width: 100%;
height: 40px;
text-align: center;
}
.nav {
width: 100%;
height: 40px;
maring: 0 auto;
text-align: center;
}
.menu-item {
display: inline-block;
width: 50px;
padding-left: 30px;
padding-right: 30px;
padding-top: 10px;
padding-bottom: 10px;
color: #777777;
}
.menu-item:hover {
background-color: black;
cursor: pointer;
border-radius: 2px;
}
Here is what I would do, some adjustment needed, not sure why the button is absolutely positioned, or what the background image is for, but here goes:
HTML:
<ul class='menu'>
<li>Link 1</li>
<li>Link 2</li>
</ul>
CSS:
.menu {
list-style-type: none;
}
.menu li {
display: inline-block;
border: 0.2em solid black;
border-radius: 10%;
padding: .5em;
background: linear-gradient(lightblue, blue);
}
.menu li a {
text-decoration: none;
color: black;
}
I'm wondering how to properly center my Logo having it within the top navigation. When it condenses everything gets messed up. I want it to turn into one of those 'square' drop down menus.
I want the links to be 'even' on either side.
HTML:
<div id="navigationcontainer">
<nav>
<ul>
<div class="col span_1_of_9">
<li>home</li>
</div>
<div class="col span_1_of_9">
<li>about</li>
</div>
<div class="col span_1_of_9">
<li>services</li>
</div>
<div class="col span_3_of_10">
<li><a id="logo" href="/"><img src="images/CarpetRepair_Logo.png" alt="Logo"></a></li>
</div>
<div class="col span_1_of_9">
<li>photos</li>
</div>
<div class="col span_1_of_9">
<li>contact</li>
</div>
<div class="col span_1_of_9">
<li><a id="FB" href="/"><img src="images/FB_Logo.jpg" alt="Facebook"></a></li>
</div>
</div>
</ul>
</nav>
CSS:
#logo {
width: 254px;
height: 170px;
margin: 0 auto;
margin-top: -34px;
padding-top: 0px;
}
a#logo {
float:left;
min-width: 50%;
width:100%; }
#FB {
}
#navigationcontainer {
width: 100%;
height: 74px;
border-bottom: 1px solid #000;
background: #06060C left top;
}
nav {
clear: both;
width: 80%; /* 1000px / 1250px */
font-size: 0.8125em; /* 13 / 16 */
max-width: 92.3em; /* 1200px / 13 */
margin: 0 auto;
margin-top: 34px;
color: #c39a6e;
}
nav ul {
font-family: 'ostrich_sansmedium';
font-size: 1.45em;
font-weight: 500;
letter-spacing: 4px;
list-style: none;
}
nav ul li {
display: block;
position: relative;
float: left;
}
nav li ul {
display: none;
}
nav ul li a {
margin-top: 8px;
display: block;
padding: 7px 15px 3px 15px;
text-align: center;
}
Thank You!
Try this
#logo {
margin-top: -34px;
padding-top: 0px;
margin: auto;
left: 0;
right: 0;
}
a#logo {
float: left;
min-width: 50%;
width: 100%;
position: fixed;
}
HTML:
<li><a id="logo" href="/"><img src="/images/srpr/logo11w.png" alt="Logo" width="170px"></a></li>
jsfiddle: http://jsfiddle.net/yka0kgvz/