Text Background color size - image

I'm wondering if I can change the background's size of the text.
I mean, I have a navbar who contain an image with text over <ul><li> then
I added a display:flex; property.
All the links are separated by little bars.
When I mouse over the links, I change the background color or image with hover. However, the background doesn't fill the area between the little bars.
nav ul {
list-style-type: none;
display: flex;
margin-top: -30px;
margin-left: -30px;
}
nav li {
margin-right: 25px;
}
nav a {
font-size: 1.2em;
color: #666060;
text-decoration: none;
}
li .news:hover {
background: url("Images/news.png");
color: white;
}
<nav>
<img src="Images/NavBar.png" alt="NavBar" />
<ul>
<li>
<a href="#">
<img src="Images/Home.png" alt="Home" title="home" />
</a>
</li>
<li> News
</li>
<li> Chat
</li>
<li> Forum
</li>
<li> Contact
</li>
</ul>
</nav>

Related

SCSS Parent Selector not applying styles to the parent based on the child

I am trying to apply a class on the parent based on the child and it doesn't seem working.
Html
<ul>
<li class="nav-item">
<a class="nav-link active">Home</a>
</li>
<li class="nav-item">
<a class="nav-link">Profile</a>
</li>
</ul>
scss
.nav-item {
$root: &;
.nav-link.active {
border: solid 1px gray!important;
background-color: lightgray;
}
a {
color: black;
font-weight: bold;
}
&-.nav-link.active {
#{$root} {
border-left: solid 3px green;
}
}
}
You can't traverse up the DOM with CSS or SASS. You should instead put the active class on the parent:
.nav-item.active .nav-link {
border: solid 1px gray!important;
background-color: lightgray;
}
.nav-item a {
color: black;
font-weight: bold;
}
.nav-item.active {
border-left: solid 3px green;
}
<ul>
<li class="nav-item active">
<a class="nav-link">Home</a>
</li>
<li class="nav-item">
<a class="nav-link">Profile</a>
</li>
</ul>

Responsive Bootstrap 4 navbar dropdown-items display as nav-items

Hello and thanks in advance for the help. Here's a link to the site in question: caulfield.co/test/originals.html
I'm attempting to create a responsive navbar in which the current dropdown-items appear as the standard nav-items after collapse.
See this image:
The dropdown-items are displaying as intended on desktop. On mobile, however, the separate dropdown is unnecessary. Here is how it displays with Bootstrap 4 out of the box:
Does anyone know of a convenient or custom solution to remove the dropdown once the navbar-collapse is in use on mobile etc such that the dropdown-items appear just like the navbar-items? Ideally, the "More" nav-link would display:none and the nav-items would continue from "Contact" to "Works On Display" seamlessly.
HTML:
<nav id="navHome" class="navbar navbar-expand-lg navbar-light sticky-top">
<div class="container-fluid max-width-940">
<a class="navbar-brand" href="index.html">
<img src="images/mb.svg" alt="Margaret Biggs" width="220px"/>
</a>
<button class="navbar-toggler togglerNoBorder" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse backgroundWhite" id="navbarNavDropdown">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="bio.html">Bio <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="originals.html">Originals</a>
</li>
<li class="nav-item">
<a class="nav-link" href="exhibition.html">Exhibition</a>
</li>
<li class="nav-item">
<a class="nav-link" href="prints.html">Prints</a>
</li>
<li class="nav-item">
<a class="nav-link" href="professionals.html">For Professionals</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
<li class="nav-item dropdown navDropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
More
</a>
<div class="dropdown-menu navDropdown" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="works-on-display.html">Works on Display</a>
<a class="dropdown-item" href="poetry.html">Poetry</a>
<a class="dropdown-item" href="commissions.html">Commissions</a>
<a class="dropdown-item" href="blog.html">Blog</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
CSS:
.navbar-right {
float:right;
}
.togglerNoBorder{
border: 0px solid transparent;
}
.nav940{
max-width:940px;
margin:0 auto;
}
#navHome {
color:rgb(34, 34, 34);
font-size:13px;
font-weight:400;
line-height:16px;
text-transform:uppercase;
background-color:white;
height:60px;
box-shadow: 0 0 18px -4px #000;
}
#navHome a{
color:rgb(34, 34, 34);
}
#navHome a:hover{
color:#165fa5;
}
.navDropdown {
font-size:13px;
}
.navDropdown a:hover {
background-color:white;
}
.backgroundWhite{
background-color:white;
}
.nav-item{
padding-left:10px;
}
.dropdown-item {
padding-top:10px;
}
.navbar-brand {
margin-bottom:3px;
}
.dropdown-menu {
top:45px;
}
Use a #media query for mobile (<992px) to show the dropdown-menu as normal nav-links...
#media (max-width: 992px) {
.dropdown-toggle {
display: none;
}
.dropdown-menu {
display: block;
position: relative;
border-width: 0;
padding: 0;
margin: 0;
}
.dropdown-item {
padding: .5rem 0rem;
color: rgba(0,0,0,.5);
}
}
https://www.codeply.com/go/lAAQOwhAx0
Based on the excellent answer by #Zim, I modified the style a bit to fit one by side in a dark navbar. Tested with Bootstrap 5, but I guess it should work in Bootstrap 4 as well.
#media (max-width: 992px) {
.dropdown-toggle {
display: none;
}
.dropdown-menu {
position: relative;
display: contents;
border-width: 0;
padding: 0;
margin: 0;
color: transparent;
}
.dropdown-item {
color: white;
background-color: black;
display: inline;
}
}

Firefox 46 can't see child div for css and jquery

Hi to everyone I have a strange problem with Firefox 46, before the update my website work good, now if I go over the slider on top page it doesn't show me the custom cursor and if I click on it doesn't work the jquery function too.
On chrome, safari and also on the old version of FF it work; it's seems it can't see the div #banner because it's a child of others div containers, but why on the old version it work?
I'm confused
here's the test page
HTML code
<div class="parallax">
<header>
<div id="cont_logo">
<a class="logo" href="" rel="home"></a>
<span>L'étoile</span>
<span id="logo_text">Ristorante - Pizzeria - Steak House</span>
<span>Courmayeur</span>
</div>
<nav id="menu_lang">
<ul>
<li class="selected"><a href="" title="ita" >It</a></li>
<li><a href="" title="fra" >Fr</a></li>
<li><a href="" title="eng" >En</a></li>
</ul>
</nav>
<nav id="main_menu">
<ul>
<li>Home</li>
<li class="selected">Ristorante</li>
<li>Menu</li>
<li>Courmayeur</li>
<li>News</li>
<li>Gallery</li>
</ul>
</nav>
</header>
<div class="parallax__group">
<div class="parallax__layer parallax__layer--base">
<div id="banner">
<ul>
<li><img src="images/banner1.jpg" alt="" /></li>
<li><img src="images/banner2.jpg" alt="" /></li>
<li><img src="images/banner3.jpg" alt="" /></li>
<li><img src="images/banner4.jpg" alt="" /></li>
</ul>
</div>
</div>
<div id="overlayer">
<h2>Ristorante</h2>
</div>
</div>
CSS code
#banner{
width:100%;
overflow:hidden;
z-index:0;
position:relative;
top:0;
left:-4px;
}
#banner:not(.home):hover{cursor:url("img/zoom.cur"), auto;}
.parallax {
height: 100%;
overflow-x: hidden;
overflow-y: auto;
perspective: 1px;
width: 100%;
}
.parallax__layer--base {
bottom: 0;
left: 0;
position: relative;
right: 0;
top: 0;
transform: translateZ(-1px) scale(2);
}
.parallax__layer--back {
transform: translateZ(0px);
}
.parallax__layer--content {
position: relative;
}
.parallax__group {
position: relative;
height: 100vh;
transform-style: preserve-3d;
}
JQuery code
function zoom_banner(){
$( "#banner" ).click(function() {
$("#testa_pag, #overlayer").toggleClass('open');
});
}

3 layer li ul menu

I want to create a 3 layer li ul menu but the 3 layer is covering the second layer. Can someone help me to align the 3 layer just right next to the second layer?
I very much appreciate your comments!
Best,
W
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<HEAD><title>bla</title>
<style type="text/css">
ul {
font-family : Arial, Verdana;
font-size : 18px;
font-weight: bold;
margin : 0;
padding : 0;
list-style : none;
z-index: -10;
}
ul li {
display : block;
position : relative;
float : left;
}
li ul {
display : none;
position : relative;
}
ul li a {
display : block;
text-decoration : none;
color : #ffffff;
border-top : 0 solid #ffffff;
padding : 6px 25px 6px 25px;
background : #033a96;
margin-left : 0;
white-space : nowrap;
}
ul li a:hover {
background : #9092c7;
}
li:hover ul {
display : block;
position : absolute;
z-index: 10;
}
li:hover li {
float : none;
font-size : 14px;
z-index: 10;
}
li:hover a {
background : #9092c7;
z-index: 10;
}
li:hover li a:hover {
background : #033a96;
z-index: 10;
}
</style>
</head>
<body >
<TABLE border=0 align="center" cellPadding=0 cellSpacing=0 valign="top">
<TBODY valign="top">
<TR valign="top">
<TD width="100%" bgcolor="#FFFFFF">
<TABLE height=19 valign="top" cellSpacing=0 cellPadding=0 width="100%" border=0>
<tr>
<td height=35 bgcolor="#033a96" >
<div id="menu_about" style="position: relative; z-index: 10;">
<ul id="menu">
<li ><a class="link" href="index.htm" >Layer 1</a>
<ul>
<li >Layer 2 blblb</li>
<li >Layer 2</li>
<ul >
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
</ul>
<li>Layer 2</li>
<li>Layer 2</li>
<li>Layer 2</li>
</ul>
</li>
<li><a class="link" href="#about" data-link="second">Layer 1</a>
<ul>
<li >Layer 2 blblb</li>
<li >Layer 2</li>
<ul >
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
</ul>
<li>Layer 2</li>
<li>Layer 2</li>
<li>Layer 2</li>
</ul>
</li>
</div>
</td>
</tr>
</TABLE>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
I very much suspect you are using a WYSIWYG (like Dreamweaver) to generate your code?
Two notes on this:
Try to avoid inline styling
Don't use table-based lay-out except for tabular data. Use divs, nav, footer, header, and aside elements
For your solution:
Removed all the z-indexes, they aren't needed
You forgot to nest the 3rd level ul's in a second level li
Try to set properties like font-size on normal state elements, not hover (doesn't change)
I would advise naming your ul's and li's, or at least putting them in a logical order in your css, because this is quite messy.
The most important part that fixes your navigation is this css I added
ul li ul li ul {
margin-left: 100%;
}
It sets your nested ul's and their children's margin to the parent div's width.
So here is your complete new css:
ul {
font-family : Arial, Verdana;
font-size : 18px;
font-weight: bold;
margin : 0;
padding : 0;
list-style : none;
}
ul li {
display : block;
float : left;
}
ul li ul li ul {
margin-left: 100%;
}
li ul {
display : none;
}
ul li a {
display : block;
text-decoration : none;
color : #ffffff;
padding : 6px 25px 6px 25px;
background : #033a96;
white-space : nowrap;
}
ul li a:hover {
background : #9092c7;
}
li:hover ul {
display : block;
position : absolute;
}
li li {
float : none;
font-size : 14px;
}
li:hover a {
background : #9092c7;
}
li:hover li a:hover {
background : #033a96;
}
And your html (only the relevant part):
<div id="menu_about" style="position: relative; z-index: 10;">
<ul id="menu">
<li ><a class="link" href="index.htm" >Layer 1</a>
<ul>
<li>Layer 2 blblb</li>
<li>Layer 2</li>
<li>Layer 2
<ul >
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
</ul>
</li>
<li>Layer 2</li>
<li>Layer 2</li>
</ul>
</li>
<li><a class="link" href="#about" data-link="second">Layer 1</a>
<ul>
<li >Layer 2 blblb</li>
<li >Layer 2
<ul >
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
<li >Layer 3 Layer 3 Layer 3 Layer 3 </li>
</ul>
</li>
<li>Layer 2</li>
<li>Layer 2</li>
<li>Layer 2</li>
</ul>
</li>
</ul>
</div>

Diplay different <li> border size on tablet

I have an issue related to css viewing of webview on Android 4.0.4
I have an list : using <ul> , <li> tags.
But when show on tablet 7 inches, some <li> has a different border size (> 1px).
Here is html :
<div id="cmSettingMenuList">
<ul>
<li >11111111</li>
<li >2222222</li>
<li >33333333</li>
<li >11111111</li>
<li >2222222</li>
<li >33333333</li>
<li >11111111</li>
<li >2222222</li>
<li >11111111</li>
<li >2222222</li>
<li >33333333</li>
<li >33333333</li>
<li >11111111</li>
<li >2222222</li>
<li >33333333</li>
</ul>
</div>
I use 1 css for it:
#cmSettingMenuList ul {
width: 580px;
list-style: none;
overflow: visible;
}
#cmSettingMenuList ul li {
padding-left: 2px;
height: 58px;
line-height: 58px;
border-bottom: 1px solid #9AB2E7;
background-size: 26px;
position: relative;
}
Here is display on tablet:
http://i.stack.imgur.com/RBsBL.png
It's not same size.
Do you have any solution for it.
THANKS

Resources