I have menu bar which need to be margin-top: 150px;
But visually in Firefox looking different as on Chrome.
Header code: https://codepen.io/bugerman21/pen/rNxvyOv
Chrome:
Correct display
Firefox:
Incorrect display
HTML:
<nav>
<ul class="nav">
<li class="category"><span>Category <i class="fas fa-sort-down"></i></span>
<ul>
<li>Qwerty 1</li>
<li>Qwerty 2</li>
<li>Qwerty 3</li>
<li>Qwerty 4</li>
</ul>
</li>
<li>Cuntact us</li>
<li>FAQ</li>
</ul>
CSS:
* {
margin: 0;
pading: 0;
}
.nav li ul {
position: absolute;
margin-top: 150px;
min-width: 150px;
list-style-type: none;
display: none;
}
How to do margin-top only for the Firefox browser?
Unsuccessful attempt:
#-moz-document url-prefix() {
.nav li ul {
margin-top: 150px;
}
}
Here ya go buddy, sorry I left for the day yesterday but see the changes made and I left outlines on the elements to give a better visual reference. As it is now it will display as expected on all browsers even old internet explorer. Although you could accomplish the same thing cleaner overall, this at least gets you back on track. Cheers and welcome to StackOverflow! :)
PS : since the nav menu items don't have a fixed height you might want to consider making that something static so you can change the top: 56px to a value that places the drop down consistently no matter the width of the screen. If you make the example full screen you'll see what I mean.
header {
display: flex;
margin: 0;
padding: 0 20px;
justify-content: space-between;
align-items: center;
background-color: silver;
}
.header {
grid-area: header;
background-color: #1f1f1f;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
}
/*---------- Logo ----------*/
.logo {
font-family: 'Gentium Book Basic', serif;
font-size: 2.5em;
color: #808080;
}
/*---------- Nav menu ----------*/
.nav {
list-style-type: none;
display: flex;
justify-content: flex-start;
margin: 0;
}
.nav > li {
text-decoration: none;
font-family: 'Roboto', sans-serif;
color: #ffffff;
transition: background-color .25s ease;
}
.nav a {
display: block;
padding: 20px;
color: #ffffff;
font-size: 1em;
}
.category {
padding: 0 20px;
display: flex;
align-items: center;
position: relative;
overflow: visible;
border: red 1px solid;
}
/*---------- Sub menu ----------*/
.nav li ul {
position: absolute;
top: 56px;
left: 0;
min-width: 150px;
margin: 0;
padding: 0;
list-style-type: none;
display: none;
border: green 1px solid;
}
.nav li > ul li {
border-bottom: 1px solid #ffffff;
background-color: #1f1f1f;
}
.nav li > ul li a {
text-transform: none;
}
.nav li:hover > ul {
display: block;
}
.nav > li:hover {
background-color: #404040;
/* box-shadow: -5px 5px #1f1f1f; */
}
.nav li ul > li:hover {
background-color: #404040;
}
/*---------- Search & Profile----------*/
.search_and_profile {
display: flex;
align-items: center;
}
.search_and_profile > p {
margin: 0;
color: #ffffff;
}
.search-container button {
float: right;
padding: 6px 10px;
background: #e0e0e0;
font-size: 17px;
border: none;
cursor: pointer;
}
.search-container input[type=text] {
padding: 6px;
font-size: 17px;
border: none;
}
<header class="header">
<span class="logo">Qwerty</span>
<nav>
<ul class="nav">
<li class="category"><span>Category <i class="fas fa-sort-down"></i></span>
<ul>
<li><a href=#>Qwerty 1</a></li>
<li>Qwerty 2</li>
<li>Qwerty 3</li>
<li>Qwerty 4</li>
</ul>
</li>
<li>Cuntact us</li>
<li>FAQ</li>
</ul>
</nav><!-- .nav -->
<div class="search_and_profile">
<div class="search-container">
<form action="#">
<input type="text" placeholder="Search.." name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div><!-- .search-container -->
</div><!-- .search_and_profile -->
</header>
It will work for me, additionally i included color too to make sure.
Also you try this option too
#media screen and (-moz-images-in-menus:0) {
/* your style */
}
* {
margin: 0;
pading: 0;
}
.nav li ul {
position: absolute;
margin-top: 150px;
min-width: 150px;
list-style-type: none;
display: none;
}
/* Added */
#-moz-document url-prefix('') {
.nav li ul {
margin-top: 150px;
color: orange;
}
}
<div class="nav">
<ul>
<li>Home</li>
<li>About
<ul>
<li>Some text</li>
<li>Some more text</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
Related
I have hardcoded padding for each of the padding hierarchy level.
I need the solution for any of level without hardcoding padding for each level.
.jdm-nav li {
font-size: 16px;
position: relative;
}
.jdm-nav li a {
padding-left: 15px;
}
.jdm-nav li li a {
padding-left: 30px;
}
.jdm-nav li li li a {
padding-left: 45px;
}
.jdm-nav li li li li a {
padding-left: 60px;
}
li li li li ... a
Every next step could be increased by 15px.
Full code example.
There is the mobile menu with ability to dropdown each item by click dropdown icon in the right item corner. If there are the items to expand.
.jdm-nav {
background-color: white;
width: 100%;
padding: 0;
}
.jdm-nav ul {
padding: 0;
}
.jdm-nav {
list-style: none;
}
.jdm-nav li {
list-style: none;
}
.jdm-nav ul {
margin: 0;
}
.jdm-nav a {
text-align: left;
display: flex;
color: rgb(76, 92, 104);
font-weight: 500;
padding: .5em 0;
font-size: 16px;
border-bottom: 1px solid rgba(76, 92, 104, 0.1);
}
.jdm-nav li {
font-size: 16px;
position: relative !important;
}
.jdm-nav li a {
padding-left: 15px;
}
.jdm-nav li li a {
padding-left: 30px;
}
.jdm-nav li li li a {
padding-left: 45px;
}
.jdm-nav li li li li a {
padding-left: 60px;
}
.jdm-nav li {
position: relative;
}
.jdm-nav li>[data-jdm-sub-menu-switcher] {
font-size: 13px;
display: flex;
width: 100%;
height: 100%;
border-bottom: 1px solid rgba(76, 92, 104, 0.1);
position: relative;
}
.jdm-nav li {
position: relative !important;
}
.jdm-nav li.menu-item-has-children>ul {
max-height: 0;
overflow: hidden;
transition: 150ms max-height ease-out;
}
.jdm-nav li.menu-item-has-children>ul[data-jdm-state="expanded"] {
max-height: initial;
}
.jdm-nav li.menu-item-has-children> :first-child {
grid-column: 1;
}
.jdm-nav li.menu-item-has-children>[data-jdm-sub-menu-switcher] {
grid-column: 2;
}
.jdm-nav li.menu-item-has-children>ul {
grid-row: 2;
grid-column-start: 1;
grid-column-end: 3;
}
.jdm-nav li>[data-jdm-sub-menu-switcher]::after {
position: absolute;
}
.jdm-nav li>[data-jdm-sub-menu-switcher]::after {
position: absolute;
width: 1em;
height: 1em;
content: '';
clip-path: url(#prefix-mobile-dropdown-clip-mask);
font-size: 13px;
background-color: rgb(76, 92, 104);
display: inline-flex;
top: 50%;
right: 50%;
transform: translateY(-50%) translateX(50%);
}
.jdm-nav li.menu-item-has-children {
display: grid;
grid-template-columns: 100fr 15fr;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<div id="prefix-mobile-menu" class="mobile-menu-area prefix-mobile-menu" data-prefix-status="collapsed">
<nav id="mobile-menu" class="jdm-nav">
<ul id="primary-menu" class="menu-overflow">
<li id="menu-item-2420" class="menu-item-has-children">
1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu" style="" data-jdm-state="expanded">
<li id="menu-item-2418" class="menu-item-has-children">1.1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu" style="" data-jdm-state="expanded">
<li id="menu-item-2434" class="menu-item-has-children">1.1.1
<button data-jdm-sub-menu-switcher=""></button>
<ul class="sub-menu">
<li id="menu-item-2435">
1.1.1.1
</li>
<li id="menu-item-2436">1.1.1.2
</li>
<li id="menu-item-2437">1.1.1.3
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="menu-item-1832">2</li>
</ul>
</nav>
<svg width="0" height="0" viewBox="0 0 448 512">
<defs>
<clipPath
viewbox="0 0 448 512"
transform="scale(0.00223, 0.00195)"
clipPathUnits="objectBoundingBox"
id="prefix-mobile-dropdown-clip-mask">
<path fill="#000000"
d="M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"
class=""></path>
</clipPath>
</defs>
</svg>
</div>
Put the padding on the li and stretch the left of the a out by a large fixed amount.
Illustrated:
body > ul {
border: 1px solid #eee;
border-radius: 2px;
margin: 1em;
padding: 1em;
overflow: hidden;
}
ul {
list-style: none;
padding: 0;
}
li {
padding-left: 15px;
}
a {
display: block;
margin-left: -150px;
margin-right: -1em;
padding-left: 150px;
}
a:hover {
background-color: #cff;
}
<ul>
<li>
nested
<ul>
<li>
navigation
<ul>
<li>
forever
<ul>
<li>
and
<ul>
<li>
ever
</ul>
</ul>
</ul>
<li>
foo
<li>
bar
</ul>
<li>
baz
</ul>
(Notice how the clickable area of each link extends all the way to the left.)
you can use this code for solve your problem
.jdm-nav li {
font-size: 16px;
position: relative;
}
.jdm-nav li{
font-size:1.2em;
padding-left: 3em;
}
.jdm-nav li a {
background-color:red;
font-size:16px;
}
<ul class="jdm-nav">
<li>
<a>Item1</a>
<ul>
<li>
<a>Item2</a>
<ul>
<li>
<a>Item3</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
use pseudo function of css to increase the padding of every children by 15px.
I am building a navbar with hover effects over the nav items and an inline button, however, the text in my button is not lining up with the other nav items. In addition I am having trouble figuring out how to get the red hover background to space itself evenly above and below the text of my nav items. What am I doing wrong?
<nav class="navbar">
<a id="header" href="#">Adopt <span class="me">Me</span> </a>
<ul >
<div id="rightitems">
<li>About Us</li>
<li>What we do</li>
<li>Benefits</li>
<li>Our Buddies</li>
<button class="btn">Contact Us</button>
</div>
</div>
</ul>
</nav>
.btn{
display: inline;
width: auto;
text-decoration: none;
margin: 0;
}
.btn a{
margin: 0;
}
body{
background-image: url(bulldog.jpg)
}
a{
text-decoration: none;
}
nav ul{
list-style-type: none;
margin: 0;
padding:0;
text-decoration: none;
display: flex;
position: relative;
}
nav a{
margin-right: 10px;
margin-left: 10px;
padding-top: 10px;
}
.navbar{
display: flex;
justify-content: space-between;
width: 100%;
}
#rightitems{
display: flex;
}
li{
width: auto;
}
li:hover{
width: auto;
}
li:hover {
background-color: #FF4850;
color: white;
border-radius: 10px;
}
nav li:hover{
color: white;
}
nav a:hover{
color: white;
}
Looks like some duplicate selectors and a bit of redundant styling. I've made some adjustments check out this fiddle:
nav a {
margin: 10px;
text-decoration: none;
}
nav a:not('me'):hover{
color: white;
}
.navbar #rightitems li{
padding: 10px 5px;
}
https://jsfiddle.net/cf2vd64y/2/
I'm very new to Dreamweaver, CSS and HTML. So I apologise if there's any obvious mistakes or solutions.
I'm trying to figure out how to separate words in my navigation menu. Because they always seem to be centred. I've tried adding "word-spacing" and other adjustments but wasn't able to come to a solution.
Just wondering if anyone's able to offer any suggestions in how I can fix this.
Any help is much appreciated,
Thank you.
CSS
.nav {
width: 100%;
height: 40px;
margin-top: 20px;
text-align: center;
}
ul {
margin: 0 auto;
padding: 0 100px;
border: 0;
list-style: none;
}
ul li {
float: left;
text-color: white;
font: Helvetica;
font-size: 100%;
outline: 0 none;
width: 100%;
}
HTML
<div class="menu">
<ul class="nav">
<li id="nav-products">Products</li>
<li id="nav-contact">Contact</li>
<li id="nav-about">About</li>
</ul>
</div>
Remove width:100% from li so menu start from left side
.nav {
width: 100%;
height: 40px;
margin-top: 20px;
text-align: center;
}
ul {
margin: 0 auto;
padding: 0 100px;
border: 0;
list-style: none;
}
ul li {
float: left;
color: white;
font: Helvetica;
font-size: 100%;
outline: 0 none;
}
ul li + li{
margin-left:10px;
}
<div class="menu">
<ul class="nav">
<li id="nav-products">Products</li>
<li id="nav-contact">Contact</li>
<li id="nav-about">About</li>
</ul>
</div>
or You want menu start from center remove float:left from li and add display: inline-block
.nav {
width: 100%;
height: 40px;
margin-top: 20px;
text-align: center;
}
ul {
margin: 0 auto;
padding: 0 100px;
border: 0;
list-style: none;
}
ul li {
display: inline-block;
color: white;
font: Helvetica;
font-size: 100%;
outline: 0 none;
}
ul li + li{
margin-left:10px;
}
<div class="menu">
<ul class="nav">
<li id="nav-products">Products</li>
<li id="nav-contact">Contact</li>
<li id="nav-about">About</li>
</ul>
</div>
Bit new at CSS and been looking around at various sites and bits of code trying to get a centered drop down menu which I managed to get :).
However as soon as I added some images to make up the heading the menu shifted off to the left and I have not been able to budge it ever since, any help? Code is below.
<style type="text/css">
<!--
body {
background-image: url();
background-color: #0099FF;
}
.style1 {color: #FFCC00}
.style2 {color: #FF9900}
.style3 {
color: #FFCC00;
font-weight: bold;
font-size: 12px;
}
.style4 {
color: #000099;
font-weight: bold;
}
.style5 {color: #000099; font-weight: bold; font-size: 12px; }
.style6 {color: #000099}
* { padding: 0; margin: 0; }
body { padding: 5px; }
ul { list-style: none; margin: auto}
ul li { float: left; padding-right: 0px; position: relative; }
ul a { display: table-cell; vertical-align: middle; width: 100px; height: 50px; text-align: center; background-color: #0099EE; color: #000000; text-decoration: none; border: 1px solid #000000;}
ul a:hover { background-color: #0066FF; }
li > ul { display: none; position: absolute; left: 0; top: 100%; }
li:hover > ul { display: inline; }
li > ul li { padding: 0; padding-top: 0px; }
#menu-outer {
height: 84px;
background: url(images/bar-bg.jpg) repeat-x;
}
.table {
display: table;
margin: 0 auto;
}
ul#horizontal-list {
min-width: 696px;
list-style: none;
padding-top: 20px;
}
ul#horizontal-list li {
display:inline
}
-->
</style></head>
<body>
<div id="menu-outer"></div>
<div class="table"></div>
<div align="center"><img src="logo_with_words_3.jpg" width="172" height="145"><img src="heading.gif" width="557" height="69"><img src="logo_with_words_3.jpg" width="172" height="145">
</div>
<ul id="horizontal-list">
<li>
Home
</li>
<li>About Us
<ul>
<li>History</li>
<li>Guest Comments</li>
</ul>
<li>News</li>
<li>Accommodation
<ul>
<li>Rooms</li>
<li>Bedrooms</li>
<li>St Joseph's Annexe</li>
</ul>
<li>Visiting St Katharine's
<ul>
<li>Retreats</li>
<li>B&B</li>
<li>Events</li>
<li>Conferences</li>
<li>Catering</li>
</ul>
<li>Contact Us
<ul>
<li>Find Us</li>
</ul>
<li>Walled Garden</li>
<li>Sue Ryder Legacy
<ul>
<li>Sue Ryder</li>
<li>Prayer Fellowship</li>
<li>LRWMT</li>
</ul>
</ul>
</body>
You aren't really using a table, but you can add something like this: #horizontal-list {margin: auto; width: 850px;}
JS Fiddle with your code
I really don't know what's the problem with my code...
The cell is positioned relative and the form is positioned absolute. In every browsers it works as it should but not Firefox...
Does it have problems with table CSS?
CSS
.table { display: table; width:100%; height:100%; table-layout: fixed; }
.row { display: table-row; height: 1px; }
.cell { display: table-cell; vertical-align: middle; position: relative; }
.menu .cell { width: 33.33%; border: 1em solid #000; font-size: 1.14em;
background: #fff; background-clip: padding-box; vertical-align: top; position: relative; }
.menu .cell header { padding:.5em 1em; background-color: #383430; color: #fff; line-height: 1.2; position: relative; }
.menu .cell .content { padding:2em 1em 3em 1em;}
.menu .cell h3 { font-size: 1em; text-transform: uppercase; text-decoration: underline; font-weight:300;}
.menu .cell ul { margin: 0; padding: 0; list-style: none; }
.menu .cell li { line-height: 1.4; padding:0.25em 0; border-bottom: 1px solid #ecece6;}
.menu .cell li:last-child { border-bottom: none; margin-bottom: 0;}
.menu .like header:before { content : 'on aime !'; position: absolute; bottom: 100%; left: 1em;
text-transform: uppercase; font-size: .8em; padding: 3.5em .5em .5em .5em; border-radius: 1em 1em 0 0;
background: #dd582a url(imgs/on-aime.png) center .5em no-repeat; box-shadow: 0px 0px 2px 0 rgba(0,0,0,.5); }
.menu .favorite { position: absolute; bottom: -.75em; right: -.75em; display: block; width: 100%; overflow: hidden;}
.menu .favorite input { position: absolute; top: -30em;}
.menu .favorite label,
.menu .favorite label:before { background-color: #dd582a; height: 32px; white-space: nowrap;
float: right; color: #fff; background-image: linear-gradient(#dd582a 50%, #bd5d3b 100%); }
.menu .favorite label:hover,
.menu .favorite label:hover:before{background-image: linear-gradient(#bd5d3b 5%, #dd582a 50%); }
.menu .favorite label { text-align: center; font-size: 24px; width: 32px; display: block;
line-height: 28px; border-radius: 4px; cursor: pointer;}
.menu .favorite label:before { content: "Add to favorite"; display: block; position: absolute; right: 34px;
padding:0 8px; font-size: 14px; line-height:32px }
.menu .favorite input:checked + label { color: #e77248; background-color: #fff;background-image: linear-gradient(#ffffff 50%, #bfbfbf 100%); }
.menu .favorite input:checked + label:hover{background-image: linear-gradient(#bfbfbf 5%, #fff 50%);}
.menu .favorite input:checked + label:before { content: "Like"}
HTML
<div class="table menu">
<div class="row">
<div class="cell">
<div >
<header>100 $</header>
<div class="content">
<h3>Title 1</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
</div>
<form class="favorite">
<input id="bal-menu2" type="checkbox" name="bal-menu2" value="favorite" />
<label for="bal-menu2">♥</label>
</form>
</div>
</div>
<div class="cell">
<div >
<header>100 $</header>
<div class="content">
<h3>Title 1</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
</div>
<form class="favorite">
<input id="bal-menu2" type="checkbox" name="bal-menu2" value="favorite" />
<label for="bal-menu2">♥</label>
</form>
</div>
</div>
</div></div>
Here's a fiddle
http://jsfiddle.net/warface/8bWUe/2/
Look in firefox, you'll notice that the form "add to favorite" stack on each other but in other browser it positioned just fine.
Any clues on how to make it work has it should like in Chrome, Safari, IE8+,...?
EDIT
After some research... Firefox has this problem since 2000
https://bugzilla.mozilla.org/show_bug.cgi?id=63895
And they don't seem to give a middle finger about it to fix it... burn in hell Firefox !
Here's a fix that takes the modified .cell >div {position:relative} and add height:100% to the divs.
CSS
.row { display: table-row; height:100%; }
.cell div {height:100%; position: relative }
Here's the udpated fiddle
http://jsfiddle.net/8bWUe/19/
Works on FF v22.0
Make
.row
{
display: block;
position:relative
}
instead of "table-row" - that should do the trick.
I was able to get the forms placed in firefox with the following css:
.cell > div { position: relative }