Problems with responsive drop down bar - css

i have started to put together a website, that uses a drop down menu in smaller sizes.
it is http://www.southmoorac.com/newindex.html
i have two pages working, the home age and the league page, but it's the drop down menu that is giving me problems, or should i say, viewing it on an iphone.
i have tested it on a pc, chrome developer tools, and it is working fine, but when view on an iphone that gives me a problem.
i have worked out that it is one line of code that is not working on the phone that is giving me the problem, so i'm looking for a work around.
this is the releveant html:
.menu {
position: absolute;
text-align: left;
top: 0;
left: 0;
background-color: rgba($dgreen, 0.99);
width: 100%;
height: 100vh;
transform: scale(1, 0);
transition: 400ms;
transition-timing-function: cubic-bezier(1, 0, 0, 1);
transform-origin: top;
&__box {
margin: 0;
padding: 0;
list-style: none;
height: 100vh;
display: flex;
flex-direction: column;
cursor: pointer;
}
&__list-item {
#include letterspace(0.3rem);
width: 100%;
height: 100%;
// padding: 6.2vh;
border-bottom: 1px solid rgba(121, 122, 121, 0.301);
}
&__item-link {
display: flex;
align-items: center;
color: $orange;
font-size: 1rem;
text-decoration: none;
text-transform: uppercase;
height: 100%;
width: 100%;
padding: 2.2vh;
padding-left: 20%;
padding-right: 0;
&:hover,
&:focus {
background-color: $orange;
color: white;
}
}
<nav class="menu">
<ul class="menu__box">
<li class="menu__list-item"><a href="http://www.southmoorac.com/newindex.html"
class="menu__item-link menu__active uncheck"><i
class="fas fa-home menu__icon"></i>Home</a>
</li>
<li class="menu__list-item"><a href="#" class="menu__item-link uncheck"><i
class="fas fa-info menu__icon"></i>About Us</a>
</li>
<li class="menu__list-item"><a href="#" class="menu__item-link uncheck"><i
class="far fa-calendar-alt menu__icon uncheck"></i>Matches</a>
</li>
<li class="menu__list-item"><a href="http://www.southmoorac.com/new_season_summary.php"
class="menu__item-link uncheck"><i class="fas fa-trophy menu__icon ">
</i>League
Table</a>
</li>
<li class="menu__list-item"><a href="#" class="menu__item-link uncheck"><i
class="far fa-envelope-open menu__icon "></i>Contact Us</a>
</li>
</ul>
</nav>
the code that is causing the problems is the height:100% line in the &__item-link.
the iphone just does not like it.
i have tried taking it out and using veritcal padding to gain height for the a link, but that's been like trying to nail jelly on a wall between different screen heights. it gets around the iphone display problem, but is not a real solution.
i hope you can help....
thanks
malcolm

Related

CSS: Rotate3D Ipad glitch

I'm animating the dropdown of my navbar using a rotateX transform command. On desktop (every browser) works well, however on iPad it glitches (the effect moves the dropdown under the navbar for an instant). When I remove the rotation the object properly displays on every device.
I'm using TailwindCss, but to make debugging simpler I just created a couple of "fictitious" css classes resuming the core CSS classes applied by Tailwind.
Expected result [desktop] (on the left) vs actual behaviour [iPad] (on the right):
.nav{
height: 4rem;
width: 100vw;
background-color: red;
position: fixed;
z-index: 40;
}
.container{
height:100%;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
}
.button{
color:white;
padding: 4rem 2rem;
cursor: pointer;
}
.dropdown{
background-color: rgba(35, 43, 50, 0.9);
border-radius: 0.5rem;
margin:0;
padding:0;
list-style: none;
width: 14rem;
position: absolute;
overflow: hidden;
transform: perspective(999px) rotateX(-12deg);
transform-origin: top center;
}
.dropdown-item{
padding: 1rem;
--rounded-top:0;
--rounded-bottom:0;
border-top-left-radius: var(--rounded-top);
border-top-right-radius: var(--rounded-top);
border-bottom-right-radius: var(--rounded-bottom);
border-bottom-left-radius: var(--rounded-bottom);
}
.dropdown-item:hover{
background-color: rgba(102, 108, 113, 0.9);
}
.dropdonw-item.first{
--rounded-top:0.5rem;
}
.dropdonw-item.last{
--rounded-bottom:0.5rem;
}
<nav class="nav">
<div class="container">
<div class="button">
<p>Button</p>
<ul class="dropdown">
<li class="dropdown-item first">Item 1</li>
<li class="dropdown-item">Item 2</li>
<li class="dropdown-item last">Item 3</li>
</ul>
</div>
</div>
</nav>

CSS submenu parent color on hover and position of submenus

this might be an easy one.
This is how my pure css menu currently looks like:
html, body {
margin:0;
padding: 0;
font-family: arial;
}
/* Menu */
.menu__wrapper {
background: #fff;
z-index: 8000;
min-height: 30px;
box-shadow: 0px 1px 5px 0px rgba(0,0,0,0.75);
}
/* The dropdown container */
.dropdown {
float: left;
overflow: hidden;
}
/* Main links */
.menu__mainlink {
cursor: pointer;
border: none;
color: $dark-color;
padding: 5px 16px;
display: inline-block;
}
/* Sublinks */
.menu__sublink {
font-size: 16px;
padding: 5px 16px;
text-decoration: none;
display: block;
}
.menu__mainlink, .menu__sublink:hover {
color: red;
text-decoration: none;
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #fff;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Sticky header */
.menu__wrapper.sticky {
position: fixed;
background-color: #fff;
width: 100%;
top: 0px;
}
/* Dropdown button */
.sticky .dropdown .dropbtn, .sticky a {
color: #000;
}
<div class="menu__wrapper padding-left-large sticky">
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Main</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content">
<a class="menu__sublink" href="#">Information</a>
<a class="menu__sublink" href="#">Archiv</a>
<a class="menu__sublink" href="#">Kontakt</a>
<a class="menu__sublink" href="#">Impressum</a></div>
</div>
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Program</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content show">
<a class="menu__sublink" href="#">This</a>
<a class="menu__sublink" href="#">That</a>
<a class="menu__sublink" href="#">Really_long_menu_item</a>
<a class="menu__sublink" href="#">Calendar</a></div>
</div>
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Found</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content">
<a class="menu__sublink" href="#">Videos</a>
<a class="menu__sublink" href="#">Image</a>
<a class="menu__sublink" href="#">Sound</a>
<a class="menu__sublink" href="#">Text</a>
</div>
</div>
</div>
Pen: https://codepen.io/t-book/pen/yLNwRba?editors=1100
Question 1: How can I color red the parent menu item like "main" when hovering over its subitems (like Archiv or Kontakt)?
Question 2: How could I push the absolute positioned submenu left to align it under its parent? The moment I position the submenu relative it will keep the x of its parent but unfortunately, in case of really long submenu names, it pushes the next floated parent item right.
Answer 1:
.dropdown:hover> a{color:red;}
Answer 2:
remove overflow:hidden; to .dropdown
add position:relative; to .dropdown
remove width: 100%; from .dropdown-content

Centering icon with vertical-align in inline-block

I don't understand why vertical-align: middle makes an icon not being centered, but a little lower.
HTML:
<ul class="operatorscreen__buttons">
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">First icon</a>
</li>
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">Second</a>
</li>
</ul>
scss:
.operatorscreen {
&__single-button {
&:first-child {
margin-bottom: 10px;
}
}
&__link {
color: black;
text-decoration: none;
font-size: 18px;
&:before {
content: "";
display: inline-block;
width: 16px;
height: 20px;
font-size: 100px;
margin-right: 12px;
vertical-align: middle;
background-color: red;
}
}
}
As you can see, a red background is little lower than text, though it should be right in the center vertically.
Try it:
li:not(:last-child) {
margin-bottom: 10px;
}
li::before {
content: '';
width: 16px;
height: 20px;
display: inline-block;
vertical-align: sub;
background-color: red;
}
<ul>
<li>First icon</li>
<li>Second icon</li>
</ul>
When I use a ruler to measure, it looks like vertical-align: middle is behaving correctly: it is in the middle of the lower case letters.
If you want it to be "perfect" then you may need to be more precise. There are many ideas, one quick one being:
position: relative;
top: -1px; // adjust to your desire
More on vertical-align of inline elements here: https://css-tricks.com/almanac/properties/v/vertical-align/
It's actually in the middle but you need to know what is the middle.
Aligns the middle of the element with the baseline plus half the x-height of the parent.ref
Here is an illustration to show the middle of the element aligned with the baseline plus half the x-height.
.operatorscreen__single-button:first-child {
margin-bottom: 10px;
}
.operatorscreen__link {
color: black;
text-decoration: none;
font-size: 18px;
background:
/*plus half x-height*/
linear-gradient(green,green) 0 calc(16px - 0.5ex)/100% 1px no-repeat,
/*the baseline*/
linear-gradient(#000,#000)0 16px/100% 1px no-repeat;
}
.operatorscreen__link:before {
content: "";
display: inline-block;
width: 16px;
height: 20px;
font-size: 100px;
margin-right: 12px;
vertical-align: middle;
background:
linear-gradient(#000,#000) center/100% 1px no-repeat;
background-color: red;
}
<ul class="operatorscreen__buttons">
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">First icon</a>
</li>
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">Second</a>
</li>
</ul>
In your particular case, use top (or text-top, text-bottom, sub) instead of middle and you will be closer to the middle you expect:
.operatorscreen__single-button:first-child {
margin-bottom: 10px;
}
.operatorscreen__link {
color: black;
text-decoration: none;
font-size: 18px;
background: linear-gradient(#000,#000)center/100% 1px no-repeat;
}
.operatorscreen__link:before {
content: "";
display: inline-block;
width: 16px;
height: 20px;
font-size: 100px;
margin-right: 12px;
vertical-align: top;
background:linear-gradient(#000,#000) center/100% 1px no-repeat;
background-color: red;
}
<ul class="operatorscreen__buttons">
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">First icon</a>
</li>
<li class="operatorscreen__single-button">
<a class="operatorscreen__link button-link button-block button-link_outline" href="#">Second</a>
</li>
</ul>

Hovering over a menu item to highlight background of subnav

I'm trying to make it so when you hover over one of the categories in the header nav "CALLS | CHATS | MORE" the subnav below shows and the ul that is associated with the header nav changes its background color i know i can just add a class using jQuery but could i not do this with a sibling selector or something? i just think my HTML is layed out incorrectly at the moment for it to work TIA. this is what i currently have.
<header class="header">
<ul class="header__nav">
<li class="header__navItem header__navItem--calls">Calls</li>
<li class="header__navItem header__navItem--chats">Chats</li>
<li class="header__navItem header__navItem--more">More</li>
</ul>
<nav class="navigation">
<div class="navigation__wrapper cf">
<ul class="navItems navItems--calls">
<li class="navItems__item"></li>
<li class="navItems__item"></li>
<li class="navItems__item"></li>
<li class="navItems__item"></li>
<div class="bgHover"></div>
</ul>
</div>
</nav>
</header>
.header {
height: 5.8rem;
background: rgba(25, 25, 25, 0.9);
position: absolute;
width: 100%;
z-index: 999;
&__nav {
display: inline-block;
text-align: center;
font-size: 0;
left: 50%;
position: absolute;
transform: translateX(-50%);
padding: 0;
margin: 0;
}
&__navItem {
color: $white;
display: inline-block;
#include font-size(18);
padding: 0 4rem;
line-height: 5.8rem;
letter-spacing: 0.1rem;
position: relative;
cursor: default;
font-weight: 400;
text-transform: uppercase;
font-family: $lato;
&--calls {
&:hover ~ .navigation__wrapper .navItems .bgHover {
max-height: 35rem;
}
&:hover {
color: red;
}
}
}
I'm presuming you want the submenu to appear below the header nav. If so, then move your sub nav into the li tag for the corresponding header item, like so:
<li class="header__navItem header__navItem--calls">Calls
<ul class="navItems navItems--calls">
<li class="navItems__item">First</li>
<li class="navItems__item">Second</li>
<li class="navItems__item">Third</li>
<li class="navItems__item">Fourth</li>
</ul>
</li>

How can I position the font awesome expanded menu indicator directly next to the menu text?

Working on this site:
https://voyagers.wildapricot.org/
Trying to get the font awesome arrow to the right of the menu nav items (which indicates there are sub-pages) to show up immediately to the right of the text instead of with a giant space in between text and arrow.
Would appreciate any help, thank you!
Technically, this is how you would do it:
Step 1: in the following CSS rule, change the display value to inline-block.
.WaGadgetMenuHorizontal .menuInner ul.firstLevel > li > .item > a {
display: inline-block;
text-decoration: none;
text-align: center;
vertical-align: top;
white-space: nowrap;
position: relative;
font: normal 18px/26px Oswald, Helvetica, sans-serif;
overflow: hidden;
}
Step 2: In the following rule, change the right-padding to 15px (the second value in the padding rule).
.WaGadgetMenuHorizontal.menuStyle004 .menuInner ul.firstLevel > li > .item > a > span {
padding: 15px 15px 15px 10px;
...
}
Step 3: In the following, change the right offset to 0 (or equivalently 0px).
.WaGadgetMenuHorizontal .menuInner ul.firstLevel > li.dir > .item > a::after {
content: "\f107";
font-family: FontAwesome;
color: white;
position: absolute;
display: inline-block;
top: 15px;
right: 0px;
}
I am assuming that you have access to all the CSS stylesheets in your content management system (web builder platform).
If not, you need to add these rules to override the pre-existing rules, so you need to learn how to do that first. You may need to get help from the tech support people where you are hosting.
Note: I went to your website using Firefox and I inspected the various elements and tried out these three steps and that did the trick. Make sure
to check out the other major browsers (Chrome and IE).
Keep in mind that these changes will change the overall look of the navigation so you may have other visual side effects that may not be suitable for your design.
Aside: the HTML in questions looks like the following (I omitted a few wrapping div's):
<ul style="" class="firstLevel">
<li class="sel">
<div class="item"><span>Home</span></div>
</li>
<li class="">
<div class="item"> <span>Coop</span> </div>
</li>
<li class="dir">
<div class="item"><span>Resource Center</span>
<ul class="secondLevel">
<li class=" ">
<div class="item"><span>Home (Demo)</span></div>
</li>
</ul>
</div>
</li>
<li class="">
<div class="item"> <span>Events</span> </div>
</li>
<li class="dir">
<div class="item"> <span>About Us</span>
<ul class="secondLevel">
<li class=" ">
<div class="item"> <span>Donate</span> </div>
</li>
</ul>
</div>
</li>
<li class="last-child">
<div class="item"> <span>Volunteer</span> </div>
</li>
</ul>
i restructured so that it works but you have to adapt it to your case
.dir {
height: 40px;
width: 100%;
}
.item {
width: inherit;
height: inherit;
}
a {
background: blue;
height: 100%;
width: 100%;
position: relative;
display: block;
}
a:hover {
background: red;
cursor: pointer;
}
span {
color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
span:after {
content:"<";
position: absolute;
right: -20px;
}
<li class="dir">
<div class="item">
<a href="https://voyagers.wildapricot.org/Resource-Center" title="Resource Center">
<span>Resource Center</span>
</a>
</div>
</li>

Resources