When I give top: 2rem to dropdown-content it works fine but doesn't look good.
It does look fine at 3rem but dropdown just disappears when I hover it. I tried with :focus and :active still same.
body {
display: grid;
place-content: center;
}
.consumer-header__menu-label {
position: relative;
cursor: pointer;
display: flex;
padding: 0 1rem;
}
.dropdown-content {
position: absolute;
top: 3rem;
right: 0;
display: none;
background-color: #ffffff;
width: 260px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.eds-dropdown-menu__contents:hover .dropdown-content {
display: block;
}
<div class="consumer-header__menu">
<div class="dropdown-menu">
<div class="eds-dropdown-menu__contents">
<div class="consumer-header__menu-label">
<div class="dropdown-content">
<li>Why Eventbrite?</li>
<li>Pricing</li>
<li>Resources</li>
</div>
Organize
<span class="eds-dropdown-menu__icon">
Custom Icons Component
</span>
</div>
</div>
</div>
</div>
I would use the native HTML <details> element for this:
body {
display: grid;
place-content: center;
}
details {
min-width: 260px;
}
details:hover, summary:focus {
cursor: pointer;
background-color: #eee;
}
details ul {
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
<div class="consumer-header__menu">
<div class="dropdown-menu">
<div class="eds-dropdown-menu__contents">
<details>
<summary>Organize</summary>
<ul>
<li>Why Eventbrite?</li>
<li>Pricing</li>
<li>Resources</li>
</ul>
</details>
</div>
</div>
</div>
Related
I have a weird problem with my project, I tried to create drop down menu,
and I used even simple example from 3 w school and it is not working, here is my code:
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="dropdown">
<span className="span1">Mouse over me</span>
<div class="dropdown-content">
<p>Hello World!</p>
</div>
</div>
I saw solutions like .dropdown:hover +.dropdown-content and it is not working too.
This works & only hovers on text because your .dropdown has no padding to it.
In this example, I added padding & pushed down the open menu that you had position absolute on.
Now when space around is hovered, the dropdown is triggered. I also added the :focus-within tag to the css trigger, this allows a user to tab into the parent menu then the open menu.
.dropdown {
background-color:orange;
padding: 20px;
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
top:60px;
left:0;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content
{
display: block;
}
<div class="dropdown">
<span className="span1">Mouse over me</span>
<div class="dropdown-content">
<p>Hello World!</p>
</div>
</div>
Here is what i have so far. It will show link target "CONTACT INFO" just beneath navbar on Firefox developer edition and on mobile chrome.
And stops target under navbar on Edge and Chrome.
Not shure why there is different placements and what the correct placement is. Is there something missing in my code?
html {
scroll-behavior: smooth;
}
body {
background-image: url("img/topography.svg"), linear-gradient(110deg, #4a95c5, darkgrey);
/*Old Color: #0f83ca*/
font-size: 30px;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
p {
margin: 0;
}
.maindiv {
min-height: 200vh;
display: grid;
grid-gap: 0px;
grid-template-columns: [start] minmax(max-content, 1fr) [content-start] minmax(70vw, 70vw) [content-end] minmax(max-content, 1fr) [end];
grid-template-rows: minmax(200px, min-content) minmax(20px, max-content) minmax(80vh, auto) minmax(150vh, auto) minmax(100px, min-content);
}
.logo {
z-index: 0;
grid-column: start / end;
background-image: url("img/waves.jpg");
background-size: cover;
background-position: 0, 0, 0, 0;
/*border: 1px solid #000000;*/
}
/*Menubar*/
.header {
display: grid;
grid-column: start / end;
background-color: #0f83ca;
border: 1px solid #000000;
position: sticky;
top: 0;
box-shadow: 0px 3px 10px rgba(50, 50, 50, 0.75);
/*font-size: 0.5em; */
}
.menu {
justify-self: center;
margin: 0;
padding: 0;
font-weight: 900;
list-style: none;
font-size: 0;
text-align: center
}
a {
text-decoration: none;
color: black;
}
.knapp {
font-size: 18px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
grid-template: inherit;
display: inline-block;
position: relative;
}
.knapp:hover,
.active {
background-color: #0f83ca;
box-shadow: inset 0 0 3px black;
}
.knapp:hover::after,
.active::after {
content: '';
border-bottom: 3px solid #25b6de;
left: 0px;
width: 100%;
height: 100%;
top: 0;
position: absolute;
}
.bodydiv {
display: grid;
grid-template: inherit;
padding-top: 40px;
justify-self: center;
grid-column: content-start / content-end;
}
.bodydiv_under {
display: grid;
grid-template: inherit;
grid-column: content-start / content-end;
background-image: url("https://source.unsplash.com/random/800x600/?fishing");
background-size: cover;
}
.body2div {
justify-self: center;
grid-column: content-start / content-end;
}
.paragraph3 {
/*padding-top: 60px;*/
}
.footer {
grid-column: start / end;
}
<div class="maindiv">
<div class="logo"></div>
<header class="header" id="wrapper">
<ul class="menu" id="myDIV">
<a href="#">
<li class="knapp knapp1 active">HOME</li>
</a>
<a href="#">
<li class="knapp knapp2">APARTMENT</li>
</a>
<a href="#">
<li class="knapp knapp3">GALLERY</li>
</a>
<a href="#">
<li class="knapp knapp4">SEA MAP</li>
</a>
<a href="#example">
<li class="knapp knapp5">FISHING GEAR</li>
</a>
<a href="#example">
<li class="knapp knapp5">CONTACT</li>
</a>
</ul>
</header>
<div class="bodydiv">
<p class="paragraph2">
<div class="bodydiv_under"></div>
</div>
<div class="body2div">
<a id="example">
<p class="paragraph3" id="block">CONTACT INFO:</p>
</a>
</div>
<footer class="footer">
<p class="paragraph4">Her kommer en footer</p>
</footer>
</div>
It's basically because how inline <a> tag is rendered in each browser is different. Those browsers seem to have different default line-height values which affect <a id="example">...</a> element's height differently.
As a quick solution, I applied display: block in a#example {..} CSS rules. And I also added padding-top: 70px to make the text not to slide under the menu. Try below and see if it works:
html {
scroll-behavior: smooth;
}
body {
background-image: url("img/topography.svg"), linear-gradient(110deg, #4a95c5, darkgrey);
/*Old Color: #0f83ca*/
font-size: 30px;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
p {
margin: 0;
}
.maindiv {
min-height: 200vh;
display: grid;
grid-gap: 0px;
grid-template-columns: [start] minmax(max-content, 1fr) [content-start] minmax(70vw, 70vw) [content-end] minmax(max-content, 1fr) [end];
grid-template-rows: minmax(200px, min-content) minmax(20px, max-content) minmax(80vh, auto) minmax(150vh, auto) minmax(100px, min-content);
}
.logo {
z-index: 0;
grid-column: start / end;
background-image: url("img/waves.jpg");
background-size: cover;
background-position: 0, 0, 0, 0;
/*border: 1px solid #000000;*/
}
/*Menubar*/
.header {
display: grid;
grid-column: start / end;
background-color: #0f83ca;
border: 1px solid #000000;
position: sticky;
top: 0;
box-shadow: 0px 3px 10px rgba(50, 50, 50, 0.75);
/*font-size: 0.5em; */
}
.menu {
justify-self: center;
margin: 0;
padding: 0;
font-weight: 900;
list-style: none;
font-size: 0;
text-align: center
}
a {
text-decoration: none;
color: black;
}
a#example {
display: block;
padding-top: 70px
}
.knapp {
font-size: 18px;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 10px;
padding-right: 10px;
grid-template: inherit;
display: inline-block;
position: relative;
}
.knapp:hover,
.active {
background-color: #0f83ca;
box-shadow: inset 0 0 3px black;
}
.knapp:hover::after,
.active::after {
content: '';
border-bottom: 3px solid #25b6de;
left: 0px;
width: 100%;
height: 100%;
top: 0;
position: absolute;
}
.bodydiv {
display: grid;
grid-template: inherit;
padding-top: 40px;
justify-self: center;
grid-column: content-start / content-end;
}
.bodydiv_under {
display: grid;
grid-template: inherit;
grid-column: content-start / content-end;
background-image: url("https://source.unsplash.com/random/800x600/?fishing");
background-size: cover;
}
.body2div {
justify-self: center;
grid-column: content-start / content-end;
}
.paragraph3 {
/*padding-top: 60px;*/
}
.footer {
grid-column: start / end;
}
<div class="maindiv">
<div class="logo"></div>
<header class="header" id="wrapper">
<ul class="menu" id="myDIV">
<a href="#">
<li class="knapp knapp1 active">HOME</li>
</a>
<a href="#">
<li class="knapp knapp2">APARTMENT</li>
</a>
<a href="#">
<li class="knapp knapp3">GALLERY</li>
</a>
<a href="#">
<li class="knapp knapp4">SEA MAP</li>
</a>
<a href="#example">
<li class="knapp knapp5">FISHING GEAR</li>
</a>
<a href="#example">
<li class="knapp knapp5">CONTACT</li>
</a>
</ul>
</header>
<div class="bodydiv">
<p class="paragraph2">
<div class="bodydiv_under"></div>
</div>
<div class="body2div">
<a id="example">
<p class="paragraph3" id="block">CONTACT INFO:</p>
</a>
</div>
<footer class="footer">
<p class="paragraph4">Her kommer en footer</p>
</footer>
</div>
My goal:
Make a horizontal scrolling carousel just like Google (see picture)
After searching, these links provided a good start:
Enabling Horizontal Scrolling in
Flexbox
A Guide to Flexbox
I've never used flexbox before. My hunch is I need to set flex-direction:row and display:inline-flex.
Any ideas on what other CSS properties I need to use? I'd really appreciate it.
Flexbox Horizontal Carousel:
Flex Container
Make the container display: flex
Asure the items don’t wrap: flex-wrap: nowrap;
Allow the area to scroll: overflow: auto;
Momentum & ease of use for iOS: -webkit-overflow-scrolling property;
IE 10, 11 & Edge: -ms-overflow-style: -ms-autohiding-scrollbar;
.container {
display: flex;
flex-wrap: nowrap;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
Flex Items
Each item needs a flex-growth and a flex-shrink value of 0, and the flex-based property can be set to auto:
.item {
flex: 0 0 auto;
}
I'm posting here a snippet with few examples. Hope it helps!
.scroll {
display: flex;
flex-wrap: nowrap;
overflow: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
.flex {
display: flex;
flex-wrap: nowrap;
}
.logo {
flex: 0 0 120px;
}
.nav-item {
flex: 0 0 auto;
}
.example-three .logo {
display: block;
border: none;
}
.example-three .nav-item {
color: #fff;
}
header {
background: #281a41;
}
.example-one-header, .example-two-header {
border-radius: 3px;
}
.example-three-header {
border-radius: 3px 3px 0 0;
}
.example-three nav {
background: #727c87;
border-radius: 0 0 3px 3px;
}
.logo {
text-align: center;
font-weight: 700;
color: #727c87;
border-right: 1px solid rgba(114, 124, 135, 0.4);
padding: 13px 24px 12px;
}
.logo, .nav-item {
padding: 13px 16px 12px;
}
.logo:not(:last-child), .nav-item:not(:last-child) {
border-right: 1px solid rgba(114, 124, 135, 0.2);
}
* {
box-sizing: border-box;
}
body {
max-width: 360px;
margin: 5% auto;
color: #64cce3;
line-height: 1.5;
}
.logo, .nav-item {
font-size: 14px;
}
.title {
margin: 24px 0 6px;
font-size: 12px;
text-transform: uppercase;
letter-spacing: .2em;
color: #999;
}
::-webkit-scrollbar {
width: 12px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px #76daff;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.5);
}
<div class="container example-one">
<div class="title">Whole Section scroll</div>
<header class="example-one-header scroll">
<span class="logo">Company Logo</span>
<nav class="flex">
<span class="nav-item">Shop</span>
<span class="nav-item">Portfolio</span>
<span class="nav-item">Downloads</span>
<span class="nav-item">About Us</span>
<span class="nav-item">Contact Us</span>
</nav>
</header>
</div>
<div class="container example-two">
<div class="title">Inside Nav only scrolling</div>
<header class="example-two-header flex">
<span class="logo">Company Logo</span>
<nav class="scroll">
<span class="nav-item">Shop</span>
<span class="nav-item">Portfolio</span>
<span class="nav-item">Downloads</span>
<span class="nav-item">About Us</span>
<span class="nav-item">Contact Us</span>
</nav>
</header>
</div>
<div class="container example-three">
<div class="title">Separated navigation</div>
<header class="example-three-header">
<span class="logo">Company Logo</span>
</header>
<nav class="scroll">
<span class="nav-item">Shop</span>
<span class="nav-item">Portfolio</span>
<span class="nav-item">Downloads</span>
<span class="nav-item">About Us</span>
<span class="nav-item">Contact Us</span>
</nav>
</div>
You can also take a look at Andi Smith flexbox-carousel:
http://www.andismith.com/flexbox-carousel/
http://www.andismith.com/blog/2012/05/css3-flexbox-carousel/
On my image I have a progress bar in svg that wraps around image. How ever when I try and center the image it does not go into the middle. The svg does but not the image.
Question: How is it possible to make the img and svg be in middle of column.
Codepen Example Here
HTML
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="column-module">
<div class="profile-module-info">
<div class="row">
<div class="col-lg-3">
<div class="profile-avatar">
<div class="image">
<img data-src="holder.js/154x154" width="154" height="154" class="img-circle img-thumbnail" />
</div>
<svg class="mi-progressbar">
<circle id="circle" r="25%" cx="50%" cy="50%" stroke-width="10"></circle>
</svg>
</div>
</div>
<div class="col-lg-6">
</div>
<div class="col-lg-3">
<div class="profile-statistics">
<ul class="list-unstyled">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
body {
background-color: #F0F0F0;
}
.container {
margin-top: 40px;
}
.column-module {
background: #fff none repeat scroll 0 0;
border-radius: 4px;
min-height: 100px;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.08), 0 2px 4px 0 rgba(0, 0, 0, 0.12);
margin-bottom: 20px;
}
.column-module .column-module-heading {
border-bottom: 1px solid #dedede;
padding: 20px;
}
.column-module .column-module-heading {
border-bottom: 1px solid #dedede;
padding: 20px;
}
.column-module .column-module-heading .column-module-title {
color: #1f2836;
font-size: 18px;
font-weight: bold;
}
.btn-group{
display: flex;
}
.profile-avatar {
border: 1px solid #bec0c2;
position: relative;
text-align: center;
margin-left: 2rem;
margin-top: -2rem;
margin-bottom: 2rem;
}
.profile-avatar svg {
position: relative;
transform: rotate(-90deg);
fill: none;
stroke: #337ab7;
stroke-dasharray: 0 0;
}
.profile-avatar img {
position: absolute;
top: 0;
left: 0;
text-align: center;
z-index: 1;
}
svg circle.progress-bar-success{
stroke:#5cb85c;
}
svg circle.progress-bar-info{
stroke:#5bc0de
}
svg circle.progress-bar-warning{
stroke:#f0ad4e;
}
svg circle.progress-bar-danger{
stroke:#d9534f;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin: 0;
padding: 0;
}
a {
cursor: pointer;
}
Try this:
.profile-avatar img {
position: absolute;
margin: auto;
left: 0;
right: 0;
text-align: center;
z-index: 1;
}
Codepen Fork
Why text is not wrapping in IE10?
body{
background: url(http://i.imgur.com/ilgJJ1Q.gif);
margin: 0;
}
ul{
margin: 0;
padding: 0;
list-style: none;
display: flex;
height: 80px;
}
li{
display: flex;
}
ul a {
color: #fff;
display: flex;
-webkit-align-items: center;
align-items: center;
max-width: 240px;
padding: 12px 50px;
align-items: center;
text-transform: uppercase;
text-decoration: none;
}
li img{
border: 0;
margin-right: 10px;
}
li span span {
display: block;
height: 2px;
margin: 7px 0 -7px;
width: 25px;
}
li:last-child{
background: rgba(38, 46, 54, .6);
}
li:nth-child(2){ background: #a15796; }
li:nth-child(3){ background: #b48c4d; }
li:nth-child(4){ background: #3a7d7d; }
<ul class="top-level-tax">
<li>
<a href="#" >
<img src="http://i.imgur.com/SRVh4os.png">
<span>Lorem ipsum dolor<span style="background-color: #38729c;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/rBM2CYr.png">
<span>consectetur adipisicing<span style="background-color: #a05995;"></span></span>
</a>
</li>
<li>
<a href="#" class="" >
<img src="http://i.imgur.com/9dFFuH5.png">
<span>Mollitia harum<span style="background-color: #b38c51;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/7bQ73kd.png">
<span>veritatis ea ipsa<span style="background-color: #3d7d7d;"></span></span>
</a>
</li>
</ul>
https://jsfiddle.net/afelixj/79pybrh9/1/
Add max-width to the span
li span{
display: block;
max-width: 120px;
}
You need to add flex-wrap: wrap; on your <ul> to specify you want it to wrap its content.