Bold on span first letter not working - html

Example here: http://jsfiddle.net/wsAK2/
Hello I have this html code:
<ul class="sidebar-nav">
<li class="sidebar-top"></li>
<li class="active">
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-home"></i>Dashboard<i class="fa fa-angle-down"></i>
<ul id="dashboard" class="collapse">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
</ul>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-signal"></i><span>Charts</span><i class="fa fa-angle-down"></i>
<ul id="charts" class="submenu collapse">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li>Separated link
</li>
</ul>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-users"></i><span>Users</span>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-calendar-o"></i><span>Calendar</span>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-gamepad"></i><span>Services</span>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-gears"></i><span>Options</span>
</div>
<div class="menu-arrow"></div>
</li>
<li>
<div class="shadow-container">
<div class="menu-indicator"></div>
<i class="fa fa-envelope"></i><span>Email</span>
</div>
<div class="menu-arrow"></div>
</li>
</ul>
and the following css rule:
.sidebar-nav > li > div > a > span:first-letter {
font-weight:bold;
}
and here is the span element being inspected with chrome:
media="screen"
.sidebar-nav > li > div > a > span:first-letter {
font-weight: bold;
}
As you can see bold has no effect on it and I can't understand why ?
same happens in firefox too.

The problem is, that the :first-letter doesn't work on inline-element(such as span e.g), but on block/inline-block elements (e.g. p, table caption, table cell, etc).
Therefore it's better to apply :first-letter to a p instead of a span.
p:first-letter {font-weight: bold;}
If you really need that :first-letter selector on the span, you can still add display:block to the span
.sidebar-nav > li > div > a > span { display: inline-block; }

:first-letter does not appply to inline elements.
.sidebar-nav > li > div > a > span {
display: inline-block;
}
.sidebar-nav > li > div > a > span:first-letter {
font-weight:bold;
}

Per MDN:
A first line has only meaning in a block-container box, therefore the
::first-letter pseudo-element has only an effect on elements with a
display value of block, inline-block, table-cell, list-item or
table-caption. In all other cases, ::first-letter has no effect.
An easy way to fix this is to change your span displays to inline-block:
span {
display:inline-block
}
jsFiddle example

Related

How can i make active background color for two elements in nav menu

I have a vertical navbar menu with 2 blocks.
First is nav with icons, second is text of menu.
They have a different background colors. How i can make one background color for two active nav blocks?
design of menu
<div class="menu__icons">
<ul class="menu__list">
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
<li>
<a class="menu__item" href="#"><img src="http://via.placeholder.com/50" alt=""></a>
</li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item" href="#">First</a></li>
<li><a class="menu__item" href="#">Second</a></li>
<li><a class="menu__item" href="#">Third</a></li>
<li><a class="menu__item" href="#">Fourth</a></li>
</ul>
</div>
</div>
https://jsfiddle.net/levan563/1g5ucmwq/2/
Well basically if you want to toggle .active and you don't want two separate markup of list.
Notice that font-awesome is for demonstration purposes only.
.menu__item {
width: 250px;
height: 50px;
text-align: left;
}
.menu__item.active {
background-color: #e9ebfd;
}
.menu__item.active .menu__icon {
background-color: #e9ebfd;
border-left: 4px solid #2c39ec;
}
.menu__item.active .menu__title {
background-color: #e9ebfd;
}
.menu__item a:hover {
text-decoration: none;
}
.menu__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
background-color: #fafafa;
color: #2c39ec;
}
.menu__title {
display: inline-block;
padding-left: 20px;
color: #777777;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navigation-menu">
<ul class="menu__list list-unstyled">
<li class="menu__item active">
<a href="#">
<div class="menu__icon">
<i class="fa fa-tachometer-alt"></i>
</div>
<div class="menu__title">Main Dashboard</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-user"></i>
</div>
<div class="menu__title">Profile</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-bell"></i>
</div>
<div class="menu__title">Finances</div>
</a>
</li>
<li class="menu__item">
<a href="#">
<div class="menu__icon">
<i class="fa fa-calendar"></i>
</div>
<div class="menu__title">Titles</div>
</a>
</li>
</ul>
</nav>
Related Fiddle https://jsfiddle.net/mhrabiee/dojL9get/28/
As I understand take active class for both block's li and try to use font, svg icon or transparent background images instead of block images
.menu__list .active {
background-color: red;
}
<div class="menu__icons">
<ul class="menu__list">
<li><a class="menu__item active" href="#">
<img src="https://img.icons8.com/material/24/000000/tailoring-for-men.png">
</a></li>
</ul>
</div>
<div class="menu__text">
<ul class="menu__list">
<li><a class="menu__item active" href="#">First</a></li>
</ul>
</div>
Its doable using jQuery.
Assuming you have same number of list items in both blocks,
$(function(){
$('.menu__list li').on('click', function() {
var idx = $(this).index();
$('.menu__list li').removeClass('active');
$('.menu__list li:nth-child(' + idx + ')').addClass('active');
});
});
also add .active class in css and give needed style to li items also
.active{
/**your style**/
}
.active > a{
}
.active img{
}

How to center main part of navbar?

I have a navbar which has 4 anchor tag buttons in the center (home, about, services, contact). I dont know how to center it on the navbar. I have another anchor tag on the far left of the navbar (a phone number link). It appears that the part I want to center is centered between the boundary of that far left link and the far right of the page.
I cant figure out how to center these 4 tags on the grid.
Hope that makes sense, im not too good with the jargon.
<a href="tel:1-530-680-8255" style="color:grey; display:inline-block">1-530-680-
8255</a>
<a href="tel:1-530-680-8255"><i class="fas fa-phone" style="display:inline-block">
</i>1-530-680-8255</a>
</div>
<nav class="navigation nav-block secondary-navigation nav-right">
<ul>
<!-- Dropdown Cart Overview
<li>
<div class="dropdown">
<span class="cart-indication"><span class="icon-shopping-cart"></span> <span class="badge">3</span></span>
<ul class="dropdown-list custom-content cart-overview">
<li class="cart-item">
<a href="single-product.html" class="product-thumbnail">
<img src="images/design-agency/portfolio/grid/no-margins/project-6-square.jpg" alt="" />
</a>
<div class="product-details">
<a href="single-product.html" class="product-title">
Cotton Jump Suit
</a>
<span class="product-quantity">2 x</span>
<span class="product-price"><span class="currency">$</span>15.00</span>
</div>
</li>
<li class="cart-item">
<a href="single-product.html" class="product-thumbnail">
<img src="images/design-agency/portfolio/grid/no-margins/project-7-square.jpg" alt="" />
</a>
<div class="product-details">
<a href="single-product.html" class="product-title">
Cotton Jump Suit
</a>
<span class="product-quantity">2 x</span>
<span class="product-price"><span class="currency">$</span>15.00</span>
</div>
</li>
<li class="cart-item">
<a href="single-product.html" class="product-thumbnail">
<img src="images/design-agency/portfolio/grid/no-margins/project-8-square.jpg" alt="" />
</a>
<div class="product-details">
<a href="single-product.html" class="product-title">
Cotton Jump Suit
</a>
<span class="product-quantity">2 x</span>
<span class="product-price"><span class="currency">$</span>15.00</span>
</div>
</li>
<li class="cart-subtotal">
Sub Total
<span class="amount"><span class="currency">$</span>15.00</span>
</li>
<li class="cart-actions">
View Cart
<span class="icon-check"></span> Checkout
</li>
</ul>
</div>
</li> -->
<!-- Dropdown Search Module
<li>
<div class="dropdown">
<span class="icon-magnifying-glass"></span>
<div class="dropdown-list custom-content cart-overview">
<div class="search-form-container site-search">
<form action="#" method="get" novalidate>
<div class="row">
<div class="column width-12">
<div class="field-wrapper">
<input type="text" name="search" class="form-search form-element no-margin-bottom" placeholder="type & hit enter...">
<span class="border"></span>
</div>
</div>
</div>
</form>
<div class="form-response"></div>
</div>
</div>
</div>
</li> -->
<li>
<div class="v-align-middle" style="margin-left: 60px;">
<i class="fab fa-facebook-f"></i>
</div>
</li>
<li class="aux-navigation hide">
<!-- Aux Navigation -->
<a href="#" class="navigation-show side-nav-show nav-icon">
<span class="icon-menu"></span>
</a>
</li>
</ul>
</nav>
<nav class="navigation nav-block primary-navigation nav-center">
<ul>
<li class="current">Home <i class="fas fa-home"></i></li>
<li class="current">About <i class="fas fa-at"></i></li>
<li class="current">Services <i class="fas fa-wrench"></i> </li>
<li class="current">Contact <i class="fas fa-phone"></i> </li>
</ul>
</nav>
</div>
</div>
</div>
</header>
You can use floats to position elements side by side on the page and then play with the widths and padding to arrange them how you like. If you are unsure how to use CSS I suggest following some online tutorials.
nav ul {
list-style-type: none;
display: inline-block;
margin: 0px;
padding: 0px;
width: 100%;
}
nav ul li {
display: inline-block;
text-align: center;
width: 60px;
margin: 0px;
padding: 0px;
}
nav ul li span {
font-size: 0.7em;
}
nav ul li i {
font-size: 2em;
}
.left {
width: 40%;
float: left;
}
.right {
width: 60%;
float: right;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<nav>
<div class="left">
<p>000 000 0000</p>
</div>
<div class="right">
<ul>
<li><i class="fas fa-phone"></i><br><span>Contact</span></li>
<li><i class="fas fa-wrench"></i><br><span>Services</span></li>
<li><i class="fas fa-at"></i><br><span>About</span></li>
<li><i class="fas fa-home"></i><br><span>Home</span></li>
</ul>
</div>
</nav>
there is alot of existing css that came with this template. For me to run your css and html, it would change too many properties to the point where its unrecognizable. Despite that this is a perfect answer. HOWEVER: I took your css:
nav ul {
list-style-type: none;
display: inline-block;
margin: 0px;
padding: 0px;
width: 100%;
}
and i changed it to these values:
nav ul {
display: inline-block;
text-align: center;
width: 1100px;
margin: 200px;
padding: 200px;
}
Its centered. But now the container is vertically huge. Need it the original height
Screenshot
Ok lets start over. I just want to center these 4 anchor tag li's inside of this ul.
Is there someway I can wrap these four into one container, and then move them to the left with css? I just want those 4 items to appear centered in that ul.
Heres a picture of what im talking about
Below is my total header in html. Theres a lot of CSS so i dont know what to link people to but ill put what i have been playing with below.
<!-- Header -->
<header class="header header-fixed header-fixed-on-mobile header-transparent" data-bkg-threshold="100">
<div class="header-inner">
<div class="row nav-bar">
<div class="column width-12 nav-bar-inner">
<div class="logo">
<div>
<a href="tel:1-530-680-8255" style="color:grey; display:inline-block">1-530-680-
8255</a>
<a href="tel:1-530-680-8255"><i class="fas fa-phone" style="display:inline-block">
</i>1-530-680-8255</a>
</div>
</div>
<nav class="navigation nav-block secondary-navigation nav-right">
<ul>
<li class="aux-navigation hide">
<!-- Aux Navigation -->
<a href="#" class="navigation-show side-nav-show nav-icon">
<span class="icon-menu"></span>
</a>
</li>
</ul>
</nav>
<nav class="navigation nav-block primary-navigation nav-center">
<ul>
<li class="current">Home <i class="fas fa-home"></i></li>
<li class="current">About <i class="fas fa-at"></i></li>
<li class="current">Services <i class="fas fa-wrench"></i> </li>
<li class="current">Contact <i class="fas fa-phone"></i> </li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<!-- Header End -->
---CSS---
nav ul li {
display: inline-block;
text-align: center;
width: 100px;
margin: 00px;
padding: 0px;
}

Select an element with no children for HOVER

I have the following html code:
<ul class="hover amazing-menu">
<li>
item1
</li>
<li class="parent-item">
item2 <span class="fa fa-caret-down"></span>
<ul class="hover sub-menu">
<li class="parent">
sub-item1 <span class="fa fa-caret-right"></span>
<ul class="sub-menu2">
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
</ul>
</li>
</ul>
</li>
</ul>
And the following style:
.hover > li.parent-item:hover > ul.sub-menu, .hover > li.parent:hover > ul.sub-menu2{
opacity: 1 !important;}
I want to show sub menu when I hover to element with .parent-item class. It works properly, But when I hover to its children, Sub menu is shown.
Try to use display: none; and trigger the shown on the shown element :hover.
Look at this example:
ul.sub-menu,
ul.sub-menu2 {
display: none;
}
a:hover + ul.sub-menu,
a:hover + ul.sub-menu2,
ul.sub-menu:hover,
ul.sub-menu2:hover {
display: block;
}
<ul class="hover amazing-menu">
<li>
item1
</li>
<li class="parent-item">
item2 <span class="fa fa-caret-down"></span>
<ul class="hover sub-menu">
<li class="parent">
sub-item1 <span class="fa fa-caret-right"></span>
<ul class="sub-menu2">
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
<li>sub-item11</li>
</ul>
</li>
</ul>
</li>
</ul>
Fiddle example

On child hover change the css of Parent

I want to change the css of parent on hover of Child element.
<ul id="main-menu">
<li>
<a href="#">
<i class="fa fa-building-o" aria-hidden="true"></i>
Private Limited
<i class="fa fa-caret-down"></i>
</a>
<ul class="submenu">
<li>Company</li>
<li>Contact</li>
<li>Industry</li>
</ul>
</li></ ul>
What i want is if i hover on li of submenu, li of main-menu get highlighted.
As already mentioned there is no parent selector but if you recognise that you are already hovering over the parent you can achieve what you want.
A rough example:
#main-menu > li:hover > a
{
background-color: #F00;
}
#main-menu > li > .submenu > li:hover
{
background-color:#00F;
}
<ul id="main-menu">
<li>
<a href="#">
<i class="fa fa-building-o" aria-hidden="true"></i>
Private Limited
<i class="fa fa-caret-down"></i>
</a>
<ul class="submenu">
<li>Company
</li>
<li>Contact
</li>
<li>Industry
</li>
</ul>
</li>
</ul>
As other posts say there is no parent selector.
This is how it should work:
li:has(> i:hover) { /* styles to apply to the li tag */ }
What this does is check if li has a i with :hover state in it. If that's the case it applies the css. Unfortunately this is not supported yet..
There is currently no way to select the parent of an element in CSS.
If you want trigger a child element with a child element use this.
.triggerDiv{
display:none;
}
.child:hover ~.triggerDiv {
display:block
}
<div class="main">
<div class="parent">
<div class="child">
<p>Hello</p>
</div>
<div class="triggerDiv">
<p>I'm Here</p>
</div>
</div>
</div>
Here you can go..
For Apply CSS..
$("#main-menu li").mouseover(function()
{
$("#main-menu a:eq(0)").css({'color':'blue','font-weight':'bold'});
});
For Remove CSS..
$("#main-menu li").mouseout(function()
{
$("#main-menu a:eq(0)").removeAttr("style");
});
[link]
(https://jsfiddle.net/aj23whnb/)

Target specific ul inside of div to assign list-style:none to

I have a div that has two UL's inside of it. I want to apply list-style:none to the first UL's LI element (it only has one).
However, when I try to do this, it applies to the 2nd UL as well. Please help!
div.com-amazon-webstore-LeftNavBrowse-2 ul:nth-child(1) li {
list-style: none!important;
}
div.com-amazon-webstore-LeftNavBrowse-2 ul.linkList.browseLadder li {
list-style: initial;
}
<div class="com-amazon-webstore-LeftNavBrowse-2">
<ul class="linkList browseLadder">
<li> <a href="http://www.test.com/b/class=tier1&ie=UTF8">
Products
</a>
</li>
<ul class="linkList browseLadder">
<li> <span class="current"> Hot & Cold Therapy</span>
</li>
<li> <a href="http://www.test.com/b/6831886011">
PT & Chiro Supplies
</a>
</li>
<li> <a href="http://www.test.com/b/6831888011">
Massage Products
</a>
</li>
<li> <a href="http://www.test.com/b/6831889011">
Exercise & Fitness
</a>
</li>
<li> <a href="http://www.test.com/b/6831890011">
Pain Relief Gels
</a>
</li>
<li> <a href="http://www.test.comb/6831891011">
Rehabilitative Care
</a>
</li>
<li> <a href="http://www.test.com/b/6831893011">
Footcare
</a>
</li>
<li> <a href="http://www.test.com/b/6831894011">
Hand Therapy
</a>
</li>
</ul>
</ul>
</div>
div ul:first-child li {
list-style: none;}
your second list is inside first one that does not make it a direct child of div. so you can select the first list directly with.
.com-amazon-webstore-LeftNavBrowse-2 > ul > li
for the second list you can use selector
.com-amazon-webstore-LeftNavBrowse-2 > ul > li
.com-amazon-webstore-LeftNavBrowse-2 > ul > li {
background-color:gray;
}
.com-amazon-webstore-LeftNavBrowse-2 > ul > ul > li {
background-color:green;
}
<div class="com-amazon-webstore-LeftNavBrowse-2">
<ul class="linkList browseLadder">
<li> <a href="http://www.test.com/b/class=tier1&ie=UTF8">
Products
</a> </li>
<ul class="linkList browseLadder">
<li> <span class="current"> Hot & Cold Therapy</span> </li>
<li> <a href="http://www.test.com/b/6831886011">
PT & Chiro Supplies
</a> </li>
<li> <a href="http://www.test.com/b/6831888011">
Massage Products
</a> </li>
<li> <a href="http://www.test.com/b/6831889011">
Exercise & Fitness
</a> </li>
<li> <a href="http://www.test.com/b/6831890011">
Pain Relief Gels
</a> </li>
<li> <a href="http://www.test.comb/6831891011">
Rehabilitative Care
</a> </li>
<li> <a href="http://www.test.com/b/6831893011">
Footcare
</a> </li>
<li> <a href="http://www.test.com/b/6831894011">
Hand Therapy
</a> </li>
</ul>
</ul>
</div>
You can cjange background color to whatever you want.