triangle pointing arrow for popup menu - html

I have a menu (sidebar), when you hover over the corresponding menu item, a second column with a submenu is displayed. I need to make a triangle-pointer, as in the picture (in the question). I can’t understand how this can be done. Share your opinion, please. Thank!
https://i.stack.imgur.com/su151.png
.main {
font-family: PT Sans;
position: relative;
display: flex;
flex-direction: row;
min-height: 100%;
}
.main_menu {
display: flex;
flex-direction: column;
width: auto;
background-color: #38618C;
padding: 50px 0 0 0;
z-index: 1000;
}
.main_menu_content {
display: flex;
flex-direction: column;
position: sticky;
top: 50px;
width: 100%;
}
.main_menu_content_list {
display: flex;
flex-direction: column;
justify-content: space-between;
text-align: center;
height: 700px;
width: 250px;
}
.main_menu_content_list li {
list-style-type: none;
}
.main_menu_content_list a {
display: flex;
flex-direction: column;
align-items: center;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 23px;
color: #D7DFE8;
text-decoration: none;
}
.main_menu_content_list_sub_block {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 55px;
}
.main_menu_content_list_submenu {
justify-content: center;
position: absolute;
padding: 0;
margin: 0;
left: 100%;
height: 100vh;
background-color: #F0F6F8;
box-shadow: 5px 0px 20px rgba(0, 0, 0, 0.25);
top: -50px;
pointer-events: none;
opacity: 0;
transition: all linear 0.1s 0s;
width: 250px;
}
.main_menu_content_list li:hover .main_menu_content_list_submenu {
opacity: 1;
pointer-events: auto;
}
.main_menu_content_list_submenu_popup li:first-child {
margin: 50px 0 0 0;
}
.main_menu_content_list_submenu_popup li:not(:first-child) {
margin: 10px 0 0 0;
}
.main_menu_content_list li:hover > .main_menu_content_list_submenu {
display: flex;
}
.main_menu_content_list_submenu_popup a {
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 21px;
color: #38618C;
}
.main_menu_content_list_submenu_popup a:hover {
color: #38618C;
text-decoration: underline;
}
.main_menu_content_list_submenu_popup a:active {
color: #FF5964;
}
.main_content {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
max-width: 100%;
height: 100%;
}
<div class="main">
<div class="main_menu">
<div class="main_menu_content">
<ul class="main_menu_content_list">
<li><a href="">
<div class="main_menu_content_list_int"></div>Интернет
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Дополнительные услуги</li>
<li>Настройка соединения</li>
<li>Подключенные дома</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_tv"></div>Телевидение
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Новости</li>
<li>Акции</li>
<li>Аналоговое ТВ</li>
<li>Оборудование</li>
<li>Настройка каналов</li>
<li>Подключенные дома</li>
<li>Документы</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_video"></div>Видеонаблюдение,<br>домофон
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Обслуживание</li>
<li>Установка</li>
<li>Заявка на ремонт</li>
<li>Подключение</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_tvr"></div>ТВ Реклама
</a></li>
<li><a href="">
<div class="main_menu_content_list_intb"></div>Интернет для бизнеса
</a></li>
<div class="main_menu_content_list_sub_block">
<li>Оплата</li>
<li>О компании</li>
</div>
<li><a href="">
<div class="main_menu_content_list_sub_account"></div>Личный кабинет
</a></li>
</ul>
</div>
</div>
<div class="main_content">
</div>
</div>

Use this css
.main_menu_content_list > li.haveSubmenu > a:after{
content: '';
position: absolute;
border: solid 10px;
border-color: transparent #F0F6F8 transparent transparent;
right: 0;
opacity: 0;
}
.main_menu_content_list > li.haveSubmenu:hover > a:after{
opacity: 1;
}
.main {
font-family: PT Sans;
position: relative;
display: flex;
flex-direction: row;
min-height: 100%;
}
.main_menu {
display: flex;
flex-direction: column;
width: auto;
background-color: #38618C;
padding: 50px 0 0 0;
z-index: 1000;
}
.main_menu_content {
display: flex;
flex-direction: column;
position: sticky;
top: 50px;
width: 100%;
}
.main_menu_content_list {
display: flex;
flex-direction: column;
justify-content: space-between;
text-align: center;
height: 700px;
width: 250px;
}
.main_menu_content_list li {
list-style-type: none;
}
.main_menu_content_list > li.haveSubmenu > a:after{
content: '';
position: absolute;
border: solid 10px;
border-color: transparent #F0F6F8 transparent transparent;
right: 0;
opacity: 0;
}
.main_menu_content_list > li.haveSubmenu:hover > a:after{
opacity: 1;
}
.main_menu_content_list a {
display: flex;
flex-direction: column;
align-items: center;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 23px;
color: #D7DFE8;
text-decoration: none;
}
.main_menu_content_list_sub_block {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 55px;
}
.main_menu_content_list_submenu {
justify-content: center;
position: absolute;
padding: 0;
margin: 0;
left: 100%;
height: 100vh;
background-color: #F0F6F8;
box-shadow: 5px 0px 20px rgba(0, 0, 0, 0.25);
top: -50px;
pointer-events: none;
opacity: 0;
transition: all linear 0.1s 0s;
width: 250px;
}
.main_menu_content_list li:hover .main_menu_content_list_submenu {
opacity: 1;
pointer-events: auto;
}
.main_menu_content_list_submenu_popup li:first-child {
margin: 50px 0 0 0;
}
.main_menu_content_list_submenu_popup li:not(:first-child) {
margin: 10px 0 0 0;
}
.main_menu_content_list li:hover > .main_menu_content_list_submenu {
display: flex;
}
.main_menu_content_list_submenu_popup a {
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 21px;
color: #38618C;
}
.main_menu_content_list_submenu_popup a:hover {
color: #38618C;
text-decoration: underline;
}
.main_menu_content_list_submenu_popup a:active {
color: #FF5964;
}
.main_content {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
max-width: 100%;
height: 100%;
}
<div class="main">
<div class="main_menu">
<div class="main_menu_content">
<ul class="main_menu_content_list">
<li class="haveSubmenu"><a href="">
<div class="main_menu_content_list_int"></div>Интернет
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Дополнительные услуги</li>
<li>Настройка соединения</li>
<li>Подключенные дома</li>
</ul>
</div>
</li>
<li class="haveSubmenu"><a href="">
<div class="main_menu_content_list_tv"></div>Телевидение
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Новости</li>
<li>Акции</li>
<li>Аналоговое ТВ</li>
<li>Оборудование</li>
<li>Настройка каналов</li>
<li>Подключенные дома</li>
<li>Документы</li>
</ul>
</div>
</li>
<li class="haveSubmenu"><a href="">
<div class="main_menu_content_list_video"></div>Видеонаблюдение,<br>домофон
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Обслуживание</li>
<li>Установка</li>
<li>Заявка на ремонт</li>
<li>Подключение</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_tvr"></div>ТВ Реклама
</a></li>
<li><a href="">
<div class="main_menu_content_list_intb"></div>Интернет для бизнеса
</a></li>
<div class="main_menu_content_list_sub_block">
<li>Оплата</li>
<li>О компании</li>
</div>
<li><a href="">
<div class="main_menu_content_list_sub_account"></div>Личный кабинет
</a></li>
</ul>
</div>
</div>
<div class="main_content">
</div>

You can draw the arrow with border properties and add to the corresponding submenu popup ::before for styling. Then, adjust the position of the arrow with top property for each submenu.
/* Add the following CSS configuration */
li:first-child ul.main_menu_content_list_submenu_popup::before {
top: 4.5rem;
}
li:nth-child(2) ul.main_menu_content_list_submenu_popup::before {
top: 11rem;
}
li:nth-child(3) ul.main_menu_content_list_submenu_popup::before {
top: 18rem;
}
ul.main_menu_content_list_submenu_popup::before {
position: absolute;
content: "";
border-color: transparent;
border-style: solid;
left: -0.5rem;
border-width: .5rem .5rem .5rem 0;
border-right-color: #F0F6F8;
}
.main {
font-family: PT Sans;
position: relative;
display: flex;
flex-direction: row;
min-height: 100%;
}
.main_menu {
display: flex;
flex-direction: column;
width: auto;
background-color: #38618C;
padding: 50px 0 0 0;
z-index: 1000;
}
.main_menu_content {
display: flex;
flex-direction: column;
position: sticky;
top: 50px;
width: 100%;
}
.main_menu_content_list {
display: flex;
flex-direction: column;
justify-content: space-between;
text-align: center;
height: 700px;
width: 250px;
}
.main_menu_content_list li {
list-style-type: none;
}
.main_menu_content_list a {
display: flex;
flex-direction: column;
align-items: center;
font-style: normal;
font-weight: normal;
font-size: 18px;
line-height: 23px;
color: #D7DFE8;
text-decoration: none;
}
.main_menu_content_list_sub_block {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 55px;
}
.main_menu_content_list_submenu {
justify-content: center;
position: absolute;
padding: 0;
margin: 0;
left: 100%;
height: 100vh;
background-color: #F0F6F8;
box-shadow: 5px 0px 20px rgba(0, 0, 0, 0.25);
top: -50px;
pointer-events: none;
opacity: 0;
transition: all linear 0.1s 0s;
width: 250px;
}
.main_menu_content_list li:hover .main_menu_content_list_submenu {
opacity: 1;
pointer-events: auto;
}
.main_menu_content_list_submenu_popup li:first-child {
margin: 50px 0 0 0;
}
.main_menu_content_list_submenu_popup li:not(:first-child) {
margin: 10px 0 0 0;
}
.main_menu_content_list li:hover > .main_menu_content_list_submenu {
display: flex;
}
.main_menu_content_list_submenu_popup a {
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 21px;
color: #38618C;
}
.main_menu_content_list_submenu_popup a:hover {
color: #38618C;
text-decoration: underline;
}
.main_menu_content_list_submenu_popup a:active {
color: #FF5964;
}
.main_content {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
max-width: 100%;
height: 100%;
}
/* Add the following CSS configuration */
li:first-child ul.main_menu_content_list_submenu_popup::before {
top: 4.5rem;
}
li:nth-child(2) ul.main_menu_content_list_submenu_popup::before {
top: 11rem;
}
li:nth-child(3) ul.main_menu_content_list_submenu_popup::before {
top: 18rem;
}
ul.main_menu_content_list_submenu_popup::before {
position: absolute;
content: "";
border-color: transparent;
border-style: solid;
left: -0.5rem;
border-width: .5rem .5rem .5rem 0;
border-right-color: #F0F6F8;
}
<div class="main">
<div class="main_menu">
<div class="main_menu_content">
<ul class="main_menu_content_list">
<li><a href="">
<div class="main_menu_content_list_int"></div>Интернет
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Дополнительные услуги</li>
<li>Настройка соединения</li>
<li>Подключенные дома</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_tv"></div>Телевидение
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Подключение</li>
<li>Новости</li>
<li>Акции</li>
<li>Аналоговое ТВ</li>
<li>Оборудование</li>
<li>Настройка каналов</li>
<li>Подключенные дома</li>
<li>Документы</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_video"></div>Видеонаблюдение,<br>домофон
</a>
<div class="main_menu_content_list_submenu">
<ul class="main_menu_content_list_submenu_popup">
<li>Обслуживание</li>
<li>Установка</li>
<li>Заявка на ремонт</li>
<li>Подключение</li>
</ul>
</div>
</li>
<li><a href="">
<div class="main_menu_content_list_tvr"></div>ТВ Реклама
</a></li>
<li><a href="">
<div class="main_menu_content_list_intb"></div>Интернет для бизнеса
</a></li>
<div class="main_menu_content_list_sub_block">
<li>Оплата</li>
<li>О компании</li>
</div>
<li><a href="">
<div class="main_menu_content_list_sub_account"></div>Личный кабинет
</a></li>
</ul>
</div>
</div>
<div class="main_content">
</div>
</div>

Related

Need help on personal portfolio project

So on this one challenge I keep getting the error: "The height of the welcome section should be equal to the height of the viewport." I have 100vh on it but im not sure how to fix it.
html:
<header>
<nav id="navbar">
<a href="#welcome-section" id="logo-link">
<h1>Welcome</h1>
</a>
<ul class="nav-list">
<a href="#projects">
<li>Projects</li>
</a>
<a href="#profile">
<li>Profile</li>
</a>
<a href="#contact">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!--BODY-->
<body>
<section id="welcome-section">
<div class="header-text">
<h1><code>Hello World!</code></h1>
<p>My name is Nick</p>
</div>
</section>
css:
#navbar {
position: fixed;
top: 0;
height: 80px;
width: 100%;
background-color: #007cc7;
display: flex;
justify-content: space-between;
z-index: 5;
}
.nav-list {
display: flex;
margin-right: 20px;
margin-top: auto;
margin-bottom: auto;
}
.nav-list a {
display: block;
font-size: 1.5rem;
padding: 10px;
color: white;
}
.nav-list a:hover {
color: cyan;
}
#logo-link {
color: white;
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
font-size: 1.5rem;
}
#welcome-section {
height: 100vh;
margin-top: 20px;
text-align: center;
background-color: #12232e;
border-style: solid;
border-color: #203647;
border-width: 10px;
border-top: 0;
border-right: 0;
border-left: 0;
display: flex;
}
.header-text {
margin: auto;
}
#welcome-section h1 {
font-size: 5rem;
}
#welcome-section p {
font-size: 1.5rem;
}
Link to the challenge: https://www.freecodecamp.org/learn/responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage
Working Demo: https://dojo.telerik.com/EkoCUneS/2
You need to add
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
}
Remove margin-top from #welcome-section.
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
}
#navbar {
position: fixed;
top: 0;
height: 80px;
width: 100%;
background-color: #007cc7;
display: flex;
justify-content: space-between;
z-index: 5;
}
.nav-list {
display: flex;
margin-right: 20px;
margin-top: auto;
margin-bottom: auto;
}
.nav-list a {
display: block;
font-size: 1.5rem;
padding: 10px;
color: white;
}
.nav-list a:hover {
color: cyan;
}
#logo-link {
color: white;
margin-top: auto;
margin-bottom: auto;
margin-left: 10px;
font-size: 1.5rem;
}
#welcome-section {
height: 100vh;
text-align: center;
background-color: #12232e;
border-style: solid;
border-color: #203647;
border-width: 10px;
border-top: 0;
border-right: 0;
border-left: 0;
display: flex;
}
.header-text {
margin: auto;
}
#welcome-section h1 {
font-size: 5rem;
}
#welcome-section p {
font-size: 1.5rem;
}
<header>
<nav id="navbar">
<a href="#welcome-section" id="logo-link">
<h1>Welcome</h1>
</a>
<ul class="nav-list">
<a href="#projects">
<li>Projects</li>
</a>
<a href="#profile">
<li>Profile</li>
</a>
<a href="#contact">
<li>Contact</li>
</a>
</ul>
</nav>
</header>
<!--BODY-->
<body>
<section id="welcome-section">
<div class="header-text">
<h1><code>Hello World!</code></h1>
<p>My name is Nick</p>
</div>
</section>
</body>

Horizontal nav with horizontal submenu - vanishing underline

I have been asked to make horizontal navbar with a horizontal submenu as well. This behaves differently than the typical navbar, and the main issue I cannot solve is when I hover an item in the nav, it underlines and displays the submenu correctly. When I move the cursor to the submenu though, the underline disappears. I cannot figure out how to keep it underlined while mousing about the submenu.
HTML:
<!-- Beginning of Header -->
<div class='menu-container'>
<div class='menu'>
<div class='logo'>
<img
src="/images/logo.svg"
alt="Pershing's Own"
height="100"
width="150" />
</div>
<div class='calendar'>Calendar</div>
<div class='feedback'>Give Feedback</div>
<div class='tickets'><a class='red-button' href='https://www.eventbrite.com/o/the-us-army-band-pershings-own-2494510190'>Tickets</a></div>
</div>
</div>
<div class='header-container'>
<nav class='nav-container' role='navigation'>
<ul class='nav-menu'>
<li class='dropdown' tabindex='-1'>
Concerts & Events
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='/event-page/event-page.html'>Concerts</a></li>
<li><a href='#'>Special Events</a></li>
<li><a href='#'>Twilight Tattoo</a></li>
<li><a href='#'>Workshops</a></li>
</ul> <!-- End of submenu -->
</li>
<li class='dropdown' tabindex='-1'>
Vacancies
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='#'>Current Openings</a></li>
<li><a href='#'>Conducting</a></li>
<li><a href='#'>Other Army Opportunities</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Watch & Listen
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='#'>Live Webcasts</a></li>
<li><a href='#'>YouTube Channel</a></li>
<li><a href='#'>Recordings</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Meet the Band
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='/meet-the-band/soldiers.html'>Musicians</a></li>
<li><a href='/meet-the-band/ensembles.html'>Ensembles</a></li>
<li><a href='#'>Support Staff</a></li>
<li><a href='#'>Command Staff</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Engagement
<ul class='red-submenu'>
<li><a href='#'>Workshops</a></li>
<li><a href='#'>Competitions</a></li>
<li><a href='#'>Educational Outreach</a></li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- End of Header -->
CSS:
body {
width: 1200px;
margin: 0 auto;
}
.nav-container {
color: #0C275B;
display: flex;
font-weight: 700;
justify-content: center;
}
nav {
width: 100%;
height: 75px;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-menu {
display: flex;
align-self: flex-end;
margin-bottom: 0px;
padding-left: 180px;
justify-content: space-evenly;
text-transform: uppercase;
font-size: 0.9em;
width: inherit;
}
.nav-menu a:link {
text-decoration: none;
color: #0C275B;
}
.nav-menu a:visited {
text-decoration: none;
color: #0C275B;
}
.nav-menu li {
display: inline;
padding-left: 0;
}
.nav-menu:focus {
pointer-events:none;
}
.dropdown a {
text-decoration: none;
font-size: 1em;
position: relative;
transition: all 0.6s;
}
.dropdown a:after {
content: '';
width: 0;
height: 0.3em;
position: absolute;
bottom: -5px;
left: 50%;
background: #0C275B;
transition: all 0.5s;
}
.dropdown a:hover:after {
width: 100%;
left: 0;
background: #C31F3C;
}
.red-submenu {
padding-left: 25%;
visibility: hidden;
opacity: 0;
position: absolute;
transition: all 0.5s ease;
border-top: solid white 0.5rem;
left: 0;
text-transform: none;
}
.red-submenu li {
padding-left: 80px;
}
.dropdown:active .red-submenu,
.dropdown:focus .red-submenu,
.dropdown:hover > .red-submenu,
.red-submenu:hover {
visibility: visible;
opacity: 1;
background-color: #C31F3C;
display: block;
width: 100%;
}
ul li ul li {
clear: both;
width: 100%;
}
.red-submenu a:link {
text-decoration: none;
color: #FFF;
}
.red-submenu a:visited {
text-decoration: none;
color: #FFF;
}
.red-submenu li a:hover:after {
width: 0%;
background: #C31F3C;
}
body {
font-family: 'Raleway', sans-serif;
font-size: 18px;
font-style: normal;
font-weight: 300;
line-height: 1.8em;
color: #0C275B;
}
.menu-container {
color: #0C275B;
padding: 20px 0;
display: flex;
justify-content: center;
height: 60px;
}
.menu {
width: 100%;
display: flex;
justify-content: space-between;
font-size: 0.9em;
font-weight: 700;
}
.calendar {
margin-left: auto;
}
.feedback,
.tickets {
margin-left: 20px;
}
.tickets {
padding-right: 20px;
}
a.red-button {
color: #FFF;
background-color: #C31F3C;
font-family: 'Raleway', sans-serif;
font-weight: 700;
padding: 5px 10px 5px 10px;
height: 2.1em;
text-align: center;
border-radius: 10px;
text-decoration: none;
}
.logo {
width: 150px;
display: flex;
padding-left: 20px;
justify-content: flex-start;
}
I created a codepen here.
Menu has no JS - only HTML and CSS. If JS would solve this, that would be fine, but if there's a way to do it with just HTML and CSS, that would be preferable.
You should put the :hover on the li.dropdown element. So replace .dropdown a:hover:after with .dropdown:hover > a::after.
// Before
.dropdown a:hover:after {
width: 100%;
left: 0;
background: #C31F3C;
}
// After
.dropdown:hover > a::after {
width: 100%;
left: 0;
background: #C31F3C;
}
body {
width: 1200px;
margin: 0 auto;
}
.nav-container {
color: #0C275B;
display: flex;
font-weight: 700;
justify-content: center;
}
nav {
width: 100%;
height: 75px;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-menu {
display: flex;
align-self: flex-end;
margin-bottom: 0px;
padding-left: 180px;
justify-content: space-evenly;
text-transform: uppercase;
font-size: 0.9em;
width: inherit;
}
.nav-menu a:link {
text-decoration: none;
color: #0C275B;
}
.nav-menu a:visited {
text-decoration: none;
color: #0C275B;
}
.nav-menu li {
display: inline;
padding-left: 0;
}
.nav-menu:focus {
pointer-events:none;
}
.dropdown a {
text-decoration: none;
font-size: 1em;
position: relative;
transition: all 0.6s;
}
.dropdown a:after {
content: '';
width: 0;
height: 0.3em;
position: absolute;
bottom: -5px;
left: 50%;
background: #0C275B;
transition: all 0.5s;
}
.dropdown:hover > a::after {
width: 100%;
left: 0;
background: #C31F3C;
}
.red-submenu {
padding-left: 25%;
visibility: hidden;
opacity: 0;
position: absolute;
transition: all 0.5s ease;
border-top: solid white 0.5rem;
left: 0;
text-transform: none;
}
.red-submenu li {
padding-left: 80px;
}
.dropdown:active .red-submenu,
.dropdown:focus .red-submenu,
.dropdown:hover > .red-submenu,
.red-submenu:hover {
visibility: visible;
opacity: 1;
background-color: #C31F3C;
display: block;
width: 100%;
}
ul li ul li {
clear: both;
width: 100%;
}
.red-submenu a:link {
text-decoration: none;
color: #FFF;
}
.red-submenu a:visited {
text-decoration: none;
color: #FFF;
}
.red-submenu li a:hover:after {
width: 0%;
background: #C31F3C;
}
body {
font-family: 'Raleway', sans-serif;
font-size: 18px;
font-style: normal;
font-weight: 300;
line-height: 1.8em;
color: #0C275B;
}
.menu-container {
color: #0C275B;
padding: 20px 0;
display: flex;
justify-content: center;
height: 60px;
}
.menu {
width: 100%;
display: flex;
justify-content: space-between;
font-size: 0.9em;
font-weight: 700;
}
.calendar {
margin-left: auto;
}
.feedback,
.tickets {
margin-left: 20px;
}
.tickets {
padding-right: 20px;
}
a.red-button {
color: #FFF;
background-color: #C31F3C;
font-family: 'Raleway', sans-serif;
font-weight: 700;
padding: 5px 10px 5px 10px;
height: 2.1em;
text-align: center;
border-radius: 10px;
text-decoration: none;
}
.logo {
width: 150px;
display: flex;
padding-left: 20px;
justify-content: flex-start;
}
<!-- Beginning of Header -->
<div class='menu-container'>
<div class='menu'>
<div class='logo'>
<img
src="/images/logo.svg"
alt="Pershing's Own"
height="100"
width="150" />
</div>
<div class='calendar'>Calendar</div>
<div class='feedback'>Give Feedback</div>
<div class='tickets'><a class='red-button' href='https://www.eventbrite.com/o/the-us-army-band-pershings-own-2494510190'>Tickets</a></div>
</div>
</div>
<div class='header-container'>
<nav class='nav-container' role='navigation'>
<ul class='nav-menu'>
<li class='dropdown' tabindex='-1'>
Concerts & Events
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='/event-page/event-page.html'>Concerts</a></li>
<li><a href='#'>Special Events</a></li>
<li><a href='#'>Twilight Tattoo</a></li>
<li><a href='#'>Workshops</a></li>
</ul> <!-- End of submenu -->
</li>
<li class='dropdown' tabindex='-1'>
Vacancies
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='#'>Current Openings</a></li>
<li><a href='#'>Conducting</a></li>
<li><a href='#'>Other Army Opportunities</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Watch & Listen
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='#'>Live Webcasts</a></li>
<li><a href='#'>YouTube Channel</a></li>
<li><a href='#'>Recordings</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Meet the Band
<ul class='red-submenu'> <!-- Start of submenu -->
<li><a href='/meet-the-band/soldiers.html'>Musicians</a></li>
<li><a href='/meet-the-band/ensembles.html'>Ensembles</a></li>
<li><a href='#'>Support Staff</a></li>
<li><a href='#'>Command Staff</a></li>
</ul>
</li>
<li class='dropdown' tabindex='-1'>
Engagement
<ul class='red-submenu'>
<li><a href='#'>Workshops</a></li>
<li><a href='#'>Competitions</a></li>
<li><a href='#'>Educational Outreach</a></li>
</ul>
</li>
</ul>
</nav>
</div>
<!-- End of Header -->
<!-- Begin main section -->
<div class='main-container'>
</div>

Is it possible to display a child border-bottom out of the parent div?

I'm kinda confused and tried out everything I'm able to try. Searching stack overflow I couldn't find the similar problem. So a little background, I'm trying to make a navigation menu with flexbox like in the picture down below, but I can't display link's border-bottom out of its parent div. Is it even possible?
This is what I want
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.wrap {
max-width: 1170px;
padding: 0 15px;
margin: 0 auto;
}
.header {
background: #44433e;
}
.header__menu {
display: flex;
justify-content: space-between;
align-items: stretch;
}
.header__logo {
padding: 10px 0;
}
.menu__list {
display: flex;
list-style: none;
align-items: center;
}
.menu__item {
margin-left: 15px;
}
.menu__item:first-child {
margin-left: 0;
border-bottom: 3px solid #18cfab;
}
.menu__link {
display: inline-block;
font-family: "Montserrat-bold";
color: #b8b8b8;
font-size: 13px;
line-height: 42px;
text-decoration: none;
text-transform: uppercase;
}
.menu__link-active {
color: #18cfab;
}
<header class="header">
<div class="header__wrap wrap">
<nav class="header__menu menu">
<div class="header__logo">
Logo
</div>
<ul class="menu__list">
<li class="menu__item">home</li>
<li class="menu__item">about</li>
<li class="menu__item">skills</li>
<li class="menu__item">service</li>
<li class="menu__item">work</li>
</nav>
</div>
</header>
You can achieve this using an :after element with a position: absolute:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.wrap {
max-width: 1170px;
padding: 0 15px;
margin: 0 auto;
}
.header {
background: #44433e;
}
.header__menu {
display: flex;
justify-content: space-between;
align-items: stretch;
}
.header__logo {
padding: 10px 0;
}
.menu__list {
display: flex;
list-style: none;
align-items: center;
}
.menu__item {
margin-left: 15px;
position: relative;
}
.menu__item:first-child {
margin-left: 0;
}
.menu__item:first-child:after {
content: "";
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 3px;
background-color: #18cfab;
}
.menu__link {
display: inline-block;
font-family: "Montserrat-bold";
color: #b8b8b8;
font-size: 13px;
line-height: 42px;
text-decoration: none;
text-transform: uppercase;
}
.menu__link-active {
color: #18cfab;
}
<header class="header">
<div class="header__wrap wrap">
<nav class="header__menu menu">
<div class="header__logo">
Logo
</div>
<ul class="menu__list">
<li class="menu__item">home</li>
<li class="menu__item">about</li>
<li class="menu__item">skills</li>
<li class="menu__item">service</li>
<li class="menu__item">work</li>
</nav>
</div>
</header>

Menu bar (navbar) is invisible on iphone browsers

I just deployed my web app and the nav bar(menu bar) seems to be present but not visible when displayed on iphone browsers(Chrome & Safari) yet it displays perfectly on android browsers.
this is how it displays on android(perfectly):
android mobile view
image of iphone mobile view
iphone mobile view
below is the HTML code for the header:
<header class="s-header">
<div class="header__top">
<div class="header__logo">
<a class="site-logo" href="/">
<h1 class="blog_logo"
>BRICK
STORIES</h1>
</a>
</div>
<div class="header__search">
<form role="search" method="get" action="">
<!-- <span class="hide-content">Search for:</span> -->
<input type="search" style="margin:3rem auto" placeholder="search here" value="{{ request.get.q }}"
name="q">
<input type="submit" class="header__search-submit" value="Search">
</form>
</div><!-- end header__search -->
<!-- toggles -->
<span>Menu</span>
</div> <!-- end header__top -->
<nav class="header__nav-wrap">
{% if user.is_authenticated %}
<h4 style="color: white;font-style: italic;">hello {{ user.first_name }}!</h4>
{% endif %}
<ul class="header__nav">
<li>Home</li>
{% if user.is_authenticated %}
<li>Logout</li>
{% else %}
<li>Register</li>
<li>Login</li>
{% endif %}
<li class="has-children current">
Categories
<ul class="sub-menu">
<li>Lifestyle</li>
<li>Health</li>
<li>Travel</li>
<li>Fashion</li>
<!-- <li>Family</li> -->
<li>Management</li>
<li>Food</li>
</ul>
</li>
<li>About</li>
</ul> <!-- end header__nav -->
<ul class="header__social">
<li class="ss-facebook">
<a href="https://facebook.com/">
<span class="screen-reader-text">Facebook</span>
</a>
</li>
<li class="ss-twitter">
<a href="#0">
<span class="screen-reader-text">Twitter</span>
</a>
</li>
<li class="ss-instagram">
<a href="#0">
<span class="screen-reader-text">Instagram</span>
</a>
</li>
</ul>
</nav> <!-- end header__nav-wrap -->
here is the css:
.blog_logo{
font-family: 'Rajdhani', sans-serif;;
/* padding: 0rem 1.2rem; */
color:white;
letter-spacing:1rem;
font-size: 2.2rem;
padding: 0rem;
margin: 0rem;
}
.s-header {
z-index: 100;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
width: 300px;
background-color:black;
padding-top: 6.4rem;
padding-right: 3.2rem;
padding-left: 4.4rem;
overflow-y: auto;
overflow-x: hidden;
vertical-align: top;
position: fixed;
bottom: 0;
top: 0;
left: 0;
}
#media screen and (max-width:1100px) {
.s-header {
width: 100%;
background: transparent;
padding: 0;
position: static;
top: 0;
bottom: auto;
}
.header__top {
z-index: 100;
background: black;
width: 100%;
height: 78px;
position: fixed;
top: 0;
left: 0;
}
.header__logo {
color: black;
margin-top: 4px;
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
position: absolute;
top: 50%;
left: 4rem;
}
.header__logo img {
width: 120px;
height: 29px;
}
.header__nav-wrap {
z-index: 99;
background:black;
opacity: 0;
visibility: hidden;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
-ms-flex-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
margin: 0;
padding: 164px 60px 64px;
overflow-y: auto;
}
.nav-wrap-is-visible .header__top {
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.nav-wrap-is-visible .header__nav-wrap {
opacity: 1;
visibility: visible;
}
.nav-wrap-is-visible .header__search-trigger {
display: none;
}
.header__nav {
font-size: 20px;
border-top: 1px dotted rgba(255, 255, 255, 0.04);
}
.header__nav > li {
border-bottom: 1px dotted rgba(255, 255, 255, 0.04);
}
.header__nav > li > a {
line-height: 7.2rem;
}
.header__nav li.has-children > a::after {
top: 32px;
}
.header__nav li ul {
font-size: 12px;
}
.header__nav li ul a {
line-height: 4rem;
}
.header__menu-toggle {
z-index: 101;
display: block;
}
.header__search-trigger {
background-image: url(../images/icons/icon-search-w.svg);
height: 20px;
width: 20px;
top: 29px;
right: 9.8rem;
}
.header__search-trigger::before,
.header__search-trigger::after {
display: none;
}
.header__social {
margin-top: 8rem;
}
.header__social a {
height: 4.4rem;
width: 4.4rem;
}
}
#media screen and (max-width:900px) {
.header__search-form::after {
font-size: 1.5rem;
}
.header__search-form input[type="search"] {
max-width: none;
width: 75%;
font-size: 4.2rem;
}
}
.s-header {
z-index: 100;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
width: 300px;
background-color:black;
padding-top: 6.4rem;
padding-right: 3.2rem;
padding-left: 4.4rem;
overflow-y: auto;
overflow-x: hidden;
vertical-align: top;
position: fixed;
bottom: 0;
top: 0;
left: 0;
}
.header__logo a {
display: block;
margin: 0;
padding: 0;
outline: 0;
border: none;
transition: all 0.3s;
}
.header__logo img {
width: 125px;
height: 30px;
margin: 0;
}
.header__nav-wrap {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column nowrap;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
-webkit-flex: 1 1 0%;
-ms-flex: 1 1 0%;
flex: 1 1 0%;
-ms-flex-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
max-width: 100%;
background-color:black;
margin-top: 3.2rem;
}

Add rounded progress line to progress bar

I'm currently trying to program a progress bar:
.create-progress-bar {
padding: 0 !important;
margin: 25px 0;
display: flex;
}
.create-progress-bar li {
display: flex;
flex-direction: column;
list-style-type: none;
position: relative;
width: 33.3333333333%;
}
.create-progress-bar .step-inner-wrapper {
display: flex;
flex-direction: column;
align-items: center;
}
.create-progress-bar li span.step-title {
text-transform: uppercase;
font-weight: 600;
}
.create-progress-bar li span.step-icon {
font-size: 22px;
padding: 18px;
border: 3px solid;
border-radius: 100%;
margin-bottom: 6px;
font-weight: 600;
width: 26px;
text-align: center;
}
.create-progress-bar li:first-child {
align-items: flex-start;
}
.create-progress-bar li:nth-child(2) {
align-items: center;
}
.create-progress-bar li:last-child {
align-items: flex-end;
}
.create-progress-bar li::after {
content: '';
position: absolute;
width: 100%;
height: 3px;
background: #666666;
border-radius: 3px;
top: 31px;
left: -50%;
z-index: -1;
}
<ul class="create-progress-bar">
<li class="active">
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Create</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Check</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Done</span>
</span>
</li>
</ul>
Now I've the problem that I can't get the progress bars styled between each elements. It should look like this depending on the class active in each li element:
Is there someone how has an idea how to get this done?
You can do this using flexbox and :before pseudo-elements. You can create line before every li element except the first one and if the li has active class you change border color and line color.
ul {
display: flex;
align-items: center;
justify-content: space-between;
list-style-type: none;
padding-left: 0;
margin-bottom: 50px;
}
li:not(:first-child) {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
}
li:not(:first-child):before {
flex: 1;
height: 1px;
background: black;
content: '';
margin: 0 10px;
}
li.active .step-inner-wrapper {
border-color: red;
color: red;
}
li.active:before {
background: red;
}
.step-inner-wrapper {
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid black;
border-radius: 50%;
position: relative;
}
.step-title {
position: absolute;
bottom: 0;
left: 50%;
transform: translate(-50%, 100%);
}
<ul class="create-progress-bar">
<li class="active">
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Create</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Check</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Done</span>
</span>
</li>
</ul>
<ul class="create-progress-bar">
<li class="active">
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Create</span>
</span>
</li>
<li class="active">
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Check</span>
</span>
</li>
<li class="active">
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Check</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Check</span>
</span>
</li>
<li>
<span class="step-inner-wrapper">
<span class="step-icon">✔</span>
<span class="step-title">Done</span>
</span>
</li>
</ul>
So I changed your CSS completely and made some minor changes to your HTML structure. This is my fiddle:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.progress-bar {
display: flex;
width: 100%;
justify-content: space-around;
flex-flow: row;
align-items: center;
max-width: calc(100% - 40px);
margin: 0 auto;
}
.progress-bar>li:first-child {
width: auto;
}
.progress-bar>li:first-child .line {
display: none;
}
.progress-bar>li.active .tick {
border-color: red;
color: red;
}
.progress-bar>li.active .line {
background: red;
}
.progress-bar>li {
display: flex;
flex-flow: row;
width: 100%;
align-items: center;
}
.tick {
border-radius: 100%;
border: 5px solid black;
height: 30px;
width: 30px;
padding: 30px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
font-weight: 600;
position: relative;
}
.tick>span {
position: absolute;
top: 70px;
}
.line {
width: 100%;
height: 5px;
display: block;
background: black;
margin: 0 15px;
}
<ul class="progress-bar">
<li class="active">
<div class="line"></div>
<div class="tick">
✔<span>CREATE</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>CHECK</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>DONE</span>
</div>
</li>
</ul>
You will see that I removed the approach of using pseudo-classes, such as ::after, and added a div.line instead. In CSS I removed the first progress line with display: none instead of removing the div tag because it is easier to use dynamically since you don't have to care about removing the first line when prepending content. But you can also just remove it like here:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.progress-bar {
display: flex;
width: 100%;
justify-content: space-around;
flex-flow: row;
align-items: center;
max-width: calc(100% - 40px);
margin: 0 auto;
}
.progress-bar>li:first-child {
width: auto;
}
.progress-bar>li.active .tick {
border-color: red;
color: red;
}
.progress-bar>li.active .line {
background: red;
}
.progress-bar>li {
display: flex;
flex-flow: row;
width: 100%;
align-items: center;
}
.tick {
border-radius: 100%;
border: 5px solid black;
height: 30px;
width: 30px;
padding: 30px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
font-weight: 600;
position: relative;
}
.tick>span {
position: absolute;
top: 70px;
}
.line {
width: 100%;
height: 5px;
display: block;
background: black;
margin: 0 15px;
}
<ul class="progress-bar">
<li class="active">
<div class="tick">
✔<span>CREATE</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>CHECK</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>DONE</span>
</div>
</li>
</ul>
Edit #1
Based on the comments, here is a version with a soft hyphen:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.progress-bar {
display: flex;
width: 100%;
justify-content: space-around;
flex-flow: row;
align-items: center;
max-width: calc(100% - 40px);
margin: 0 auto;
}
.progress-bar>li:first-child {
width: auto;
}
.progress-bar>li.active .tick {
border-color: red;
color: red;
}
.progress-bar>li.active .line {
background: red;
}
.progress-bar>li {
display: flex;
flex-flow: row;
width: 100%;
align-items: center;
}
.tick {
border-radius: 100%;
border: 5px solid black;
height: 30px;
width: 30px;
padding: 30px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
font-weight: 600;
position: relative;
}
.tick>span {
position: absolute;
top: 70px;
max-width: 100px;
text-align: center;
}
.line {
width: 100%;
height: 5px;
display: block;
background: black;
margin: 0 15px;
}
<ul class="progress-bar">
<li class="active">
<div class="tick">
✔<span>CREATE­VERY­LONG­TEXT</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>CHECK</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>DONE</span>
</div>
</li>
</ul>
You could theoretically use hyphens: auto. But this has massive lack of browser support, as it can be seen here.
If you don't want the - dashes just use word-wrap: break-word;
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.progress-bar {
display: flex;
width: 100%;
justify-content: space-around;
flex-flow: row;
align-items: center;
max-width: calc(100% - 40px);
margin: 0 auto;
}
.progress-bar>li:first-child {
width: auto;
}
.progress-bar>li.active .tick {
border-color: red;
color: red;
}
.progress-bar>li.active .line {
background: red;
}
.progress-bar>li {
display: flex;
flex-flow: row;
width: 100%;
align-items: center;
}
.tick {
border-radius: 100%;
border: 5px solid black;
height: 30px;
width: 30px;
padding: 30px;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
font-weight: 600;
position: relative;
}
.tick>span {
position: absolute;
top: 70px;
max-width: 100px;
text-align: center;
word-wrap: break-word;
}
.line {
width: 100%;
height: 5px;
display: block;
background: black;
margin: 0 15px;
}
<ul class="progress-bar">
<li class="active">
<div class="tick">
✔<span>CREATEVERYLONGTEXT</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>CHECK</span>
</div>
</li>
<li>
<div class="line"></div>
<div class="tick">
✔<span>DONE</span>
</div>
</li>
</ul>