Change first child ::before style when .active - html

I have a menu that looks like this: http://i.stack.imgur.com/beX6i.png
The little triangle is made using ::before. I need to make it change into the color of the hover when the first child of the submenu is active (has .active class that is added from js automatically)
What should the selector look like? something like .submenu a:first-child.active?
CSS:
.submenu{
z-index:10;
position:absolute;
display:none;
background:#2b2b2b;
}
.submenu a{
font-family:'Roboto Slab';
display:block;
color:white;
background:transparent;
text-decoration:none;
text-transform:uppercase;
line-height:58px;
padding-left:8px;
padding-right:8px;
font-weight:bold;
font-size:14px;
}
.submenu a:hover{
color:#fe4817;
display:block;
background-color:#3A3939;
}
.submenu a.active{
color:#fe4817;
background-color:#3A3939;
}
.submenu a:first-child:before,
.submenu a:first-child::before{
position:absolute;
top:-8px;
left:0;
content:' ';
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 15px solid #2b2b2b;
}
.submenu a:first-child:hover:before,
.submenu a:first-child:hover::before{
border-bottom: 15px solid #3A3939;
}

It's really hard to understand your question. But I think
.submenu a:first-of-type.active:before {
border-bottom-color:#3a3939;
}
should do the job. :first-of-type might be better than :first-child in this case since :first-child could either be a heading or something alike while :first-of-type only selects the first anchor. See Selector Reference for further information.
If that doesn't work and you can provide a fiddle I'll take another look at your problem.

Related

HTML/CSS - Checklist using span and on :focus

I'm trying to set the color of a span box to red when I ':focus' on a link. The span changes color on ':active', but nothing seems to happen when I use ':focus'. The categories will output different types of products on click using angular. At the moment, when I click on one of the filters there is no indication that one of the categories has been activated, heavily impacting the UX. I'm hoping to do this with html and css only if possible.
<div class="checklist categories">
<ul>
<li><a><span></span>All</a></li>
<li><a><span></span>House Favourites</a></li>
</ul>
</div>
.checklist ul li{
font-size:14px;
font-weight:400;
list-style:none;
padding: 7px 0 7px 23px;
cursor: pointer;
}
.checklist li span{
float:left;
width:11px;
height:11px;
margin-left:-23px;
margin-top:4px;
border: 1px solid #d1d3d7;
position:relative;
}
.checklist li a{
color:#676a74;
text-decoration:none;
}
.checklist li a:hover{
color:#222;
}
.categories a:hover span{
border-color:#a6aab3;
}
.checklist .checked span{
border-color:#8d939f;
}
.checklist a:active span {
background-color: red;
}
// This code below is the issue as :focus seems to do nothing
.checklist a:focus span {
background-color: red;
}
I was given a solution for this using Angular and typescript:
Code

Trouble with CSS drop down menu

I have recently been working on a small CSS menu that I can’t get working properly. Ive been fiddling around with existing menu’s and trying to get the positioning and fonts etc to be working.
Basically first I had my main menu, which is working fine the way it should. Now when I try add a dropdown to one of the options, it really messes up and I am completely clueless to fixing this mess :S
What I need help in: Positioning the dropdown menu’s below the correct menu-item (now they always float on the left). Also I want the submenu items, to be the exact same style/size/font/etc as the main menu items, which for some reason I can’t get working either.
Any help is appreciated, I submitted the CSS / HTML Code of the menu into a pastebin file:
CSS: http://pastebin.com/rJEgvnK1
HTML: http://pastebin.com/e52RuH4r
Its not perfect but still you can figure out the positioning correctly but not the fonts. Check this jsfiddle
CSS used:
#mainMenu ul{
width:954px;
padding:0;
margin:5px 0 10px 0;
list-style-type:none;
border:solid 2px #ddd;
font-size: 18px;
text-transform: uppercase;
}
#mainMenu ul li a{
text-decoration:none;
color:#000000;
background-color:#eee;
padding:0.2em 0.6em;
border-right:0px solid white;
display:block;
}
#mainMenu a:hover{
color:#FFFFFF;
background-color:#2E9AFE;
}
#mainMenu ul li{
display:inline-block;
position: relative;
}
#mainMenu ul ul {
background-color: #eee;
display: none;
width: 133px;
height: auto;
position: absolute;
border: solid 1px #ddd;
top: 23px;
}
#mainMenu ul li:hover > ul{
display:block;
padding:0;
margin:5px 0 10px 0;
list-style-type:none;
border:solid 2px #ddd;
font-size:18px;
text-transform:uppercase;
}
#mainMenu ul ul li:hover a{
color:#FFFFFF;
background-color:#2E9AFE;
}
#mainMenu ul ul li:hover {
cursor:pointer;
}
#mainMenu ul ul li {
float:none;
padding:10px;
}
#mainMenu ul ul li{
font-size:16px;
padding:0 10px;
}
Not perfect but this should get you furter:
jsfiddle
To get the blocks below each link (IN YOUR CSS), simply remove the a-Tag from #mainMenu ul li a{
This one is a little nicer !!!

Button with Number and Text

I have a HTML button, I have to display it just like smart phone dialpad. like number and ABC etc.
<a href="" class="button">
1
<span>ABC</span>
</a>
everything is fine except the text is not visible in the button. How can I solve that ?
You just need to change the style of the span to wrap correctly.
add display: inline-block; to your a span selector so that it looks like this:
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-5px;
font-style:italic;
display: inline-block;
}
The best solution is usually the simplest. In this case, just a one line addition.
All you need to do is add a height to your button element. Here is an updated fiddle: http://jsfiddle.net/2nv7A/8/
.button {
...
height: 100px;
}
Try this:
a span {
font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-15px; // pulled up the text a little more
margin-bottom:10px; // pushed down the margin at the bottom
font-style:italic;
}
Fiddle around with these and you'll find the best one for you
DEMO HERE
U can use overflow property to show the text cutting off and then can manage height of your element.
.button {
position: relative;
width: 62px;
overflow: visible;
/*border: 1px solid black;*/
border: 1px solid black;
border-radius: 12px;
/*border-radius: 7px;*/
Outline: none;
margin-left:2px;
margin-bottom:7px;
border-color:#ccc;
}
If you remove your positioning, decrease your line-height and then remove your span height (which was set to 0 preventing it from appearing) then it seems to work fine. Here
.button {
width: 62px;
/*border: 1px solid black;*/
border: 1px solid black;
border-radius: 12px;
/*border-radius: 7px;*/
Outline: none;
margin-left:2px;
margin-bottom:7px;
border-color:#ccc;
}
a{
display:inline-block;
vertical-align:top;
text-align:center;
text-decoration:none;
font-weight:bold;
line-height:25px;
overflow:hidden;
font-size:12px;
}
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
font-style:italic;
}
Decresea the line-height property of .a AND increase the line-height of a. span.
You need to change the margins on your span. Use this CSS:
a span {font-size:8px;
text-transform:uppercase;
display:block;
text-align:center;
line-height:0em;
margin-top:-10px;
font-style:italic;
margin-bottom:15px;
}
It's because you set the display:block for the span tag, which should be display:inline-block;:
a span {
font-size:8px;
text-transform:uppercase;
display:inline-block; /* <---- here */
text-align:center;
line-height:0em;
margin-top:-5px;
font-style:italic;
}
Fiddle

CSS dropdown menu z-index

I'm trying to do a dropdown menu that I designed with photoshop. However, there is a border in the top of this menu. The image, can explain it better:
Using CSS, all I get is a line that covers more that it is designed to. I tryed to use z-index position to make, but without success. Take a look at my code:
nav{
display: inline;
font-weight:900;
text-transform:uppercase;
font-size:13px;
margin-left:95px;
}
.menu > li > a {
width:auto;
padding:10px 20px 10px 10px;
background-image:url('img/seta_menu.png');
background-repeat:no-repeat;
background-position:right 50%;
}
.menu>li{
width:auto;
margin-right:45px;
padding:10px;
border-left: solid 1px #F8FAFA;
border-right: solid 1px #F8FAFA;
border-top:solid 1px #F8FAFA;
border-bottom:solid 1px #F8FAFA;
}
.menu>li:hover{
border-left: solid 1px #bdc9c5;
border-right: solid 1px #bdc9c5;
border-top:solid 1px #bdc9c5;
border-bottom:solid 1px #bdc9c5;
background-color:white;
}
nav>div{
display:inline;
}
nav>div>ul{
display: inline;
}
.menu li{
display: inline-table;
}
.menu>li:hover >ul{
display:block;
}
.sub-menu{
position:absolute;
display:none;
padding:10px;
margin-left:-11px;
margin-top:10px;
border-left: solid 1px #bdc9c5;
border-right: solid 1px #bdc9c5;
border-bottom:solid 1px #bdc9c5;
/*border-top:solid 1px #bdc9c5;*/
background-color:white;
}
.sub-menu ol, ul {
padding:0px;
margin:0px;
}
.sub-menu > li{
display:block;
}
http://jsfiddle.net/btgfE/
Problem solved...
jsfiddle: http://jsfiddle.net/btgfE/2/
1) uncomment the top border of the .sub-menu
2) comment out the bottom border of the .menu>li:hover
3) give .sub-menu the css rule z-index:-1;
4) decrease the margin-top of .sub-menu to 9px
Really what this is doing is letting the top level menu item slightly overlap ontop of the sub-menu item's top border, giving the appearance you are looking for
I have edited your fiddle here:
http://jsfiddle.net/btgfE/4/
I gave the .submenu a z-index of -1, this fixed it.
I also changed the colours so they are more easily visible. You will want to set the green to white, I did this so that you can see the border is on top of the sub-menu's border

how to get rid of the border-bottom by css?

how to get rid of the border-bottom which under test text in the li when the mouse hover on the test text by css?
the html :
<div class="rank">
<ul>
<li class="tab1 active">test</li>
<li class="tab2">one</li>
</ul>
</div>
<div class="content">....</div>
my style(it's doesn't get rid of the bottom under test text):
.active{
background-color:#FFFFFF;
}
rank ul li{
float:left;
border:1px solid #D5D5D5;
border-bottom:none;
}
.content{
clear:both;
border-top:1px solid #D5D5D5;
}
ps: why when i use overflow:hidden to rank div, it can prevent the float to the content div?
#zhuanzhou; may be you have to play with margin padding
for example
.rank ul{
border-bottom:1px solid #D5D5D5;
}
.clr{
clear:both;
}
.active{
background-color:#FFFFFF;
padding-bottom:1px;
margin-bottom:-1px;
}
.rank ul li{
float:left;
border:1px solid #D5D5D5;
border-bottom:none;
margin-right:10px;
}
.content{
clear:both;
border-top:1px solid #D5D5D5;
}
check live demo http://jsfiddle.net/PBBED/
NOTE:in my example i am using clear:both instead of overflow:hidden for clear floated child element.
.active {
background-color: #ffffff;
border-bottom: 1px solid #ffffff;
margin-bottom: -1px;
}
.active{
background-color:#FFFFFF;
}
ul li{
display:inline;
}
li{
border-bottom:1px solid;
}
li:hover{
border-bottom:none;
}
.content{
clear:both;
border-top:1px solid #D5D5D5;
}
Remove line 7 in your css then start a new selector using the css psuedo class :hover at the end
rank ul li:hover {
border-bottom: none;
}
Although, older browser will disregard that unless it is on an a tag.