CSS active menu item - css

Hi I'm trying to modify a web template which doesn't have different colors for active menu items. I've tried various changes to be able to adjust this. Any ideas? Here is the css:
/** TOP MENU **/
.top_menu .moduletable {
margin:0;
}
.top_menu li {
margin:0px 0 0 5px ;
padding:0;
float:left;
height:100px;
list-style : none;
background : transparent url(../images/top_menu_left.png) 0 0 no-repeat;
opacity:0.6;
-ms-filter: "prodig:DXImageTransform.Microsoft.Alpha(Opacity=60)"; /* fix IE8 */
filter: apha(opacity = 60); /* fix IE7 */
-webkit-transition : all 0.4s ease-in-out;
-moz-transition : all 0.4s ease-in-out;
-ms-transition : all 0.4s ease-in-out;
-o-transition : all 0.4s ease-in-out;
transition : all 0.4s ease-in-out;
}
.top_menu li:hover {
opacity:1;
-ms-filter: "prodig:DXImageTransform.Microsoft.Alpha(Opacity=100)"; /* fix IE8 */
filter: apha(opacity = 100); /* fix IE7 */
}
.top_menu li a {
display:block;
color: #24221E/*8c8c8c*/;
text-shadow:0 0 3px #fff;
background : transparent url(../images/top_menu_right.png) 100% 0 no-repeat;
text-decoration:none;
text-transform: none;
font-weight:bold;
font-size:90%;
margin-right:-13px;
padding: 60px 22px 4px 20px;
height:40px;
}
Any help would be greatly appreciated

I see that you are using Joomla as a Content Management System and you have to use a class to style an item, for example active, and then you can use CSS to assign a different styling for this item.
.active {
text-decoration: underline;
font-weight: bold;
}
If you want to change the color of the link you need to adress the a tag directly using the following code.
.active a {
color: red;
}
You might find this answer also useful: Joomla - how to hightlight the menu item for active page

Related

Hide and show elements using css

I am making my first steps learning html, css and php. I made some courses on internet and now I decided to make a site using Wordpress so I can continue learning from the practice.
The thing is that I made a page with a custom field for a video and a custom field for a description.
As you can see in the picture I'm hiding all the text of the description using a details tag called About in html.
When I click on about I see this:
And there is my question:
How can I hide some elements when other elements are displayed? I would like to open this page and only see the text and a close button. It means that when details is open, the page should not display the "menu" link and the "strange magic" title.
I already tryied this but it doesn't work:
details[open] .entry-title .menu-toggle{
display: none;
}
Do you have some suggestion? It is something possible to do using css?
I think you should try this, maybe it will help you..
label {
display:block;
margin:20px 0 10px 0;
}
label:hover {
text-decoration:underline;
}
input {
position:absolute;
left:-999em
}
.hide {
width:50%;
border:1px solid #000;
background:rgba(148, 148, 148, 0.33);
box-shadow: 3px 3px 10px;
max-height:999em;
opacity:1;
height:auto;
overflow:hidden;
transition:opacity .5s linear;
}
.hide p {
padding:10px;
margin:0
}
input[type=checkbox]:checked + div {
opacity:0;
max-height:0;
border:none;
transition:opacity .5s linear, max-height .5s linear;
}
.follow{
border-top:1px solid blue;margin:0;
}
Demo: https://jsfiddle.net/Pratik_009/t41nn2nh/

How to make div css background hover

I would like to make div css background hover effect on my very top menu to white(#fff).
It's not a menu link. It's background(rectangular a little bit transparency table. A full width).
If you use F12, you can see 'div.top-strip.color-site-white'.
My site is http://www.samgyoyu.com/. And I would like to make hover effect like this site. http://www.herschelsupply.com/.
Thank you and have a nice day:)
add following line to your css
#secondary-nav ul li:nth-child(n+2) a:hover
{
color: black;
border-bottom: 2px solid black;
}
Make the background color as transparent
#masthead .color-site-white {
background-color:rgba(255,255,255,.5);
position:fixed;
left: 0;
right: 0;
}
#masthead .color-site-white:hover {
background-color:rgba(255,255,255,1);
}
For IE 7, 8 - This will not support (RGBA) so you must use a png transprent image for background and div:hover also not support for IE so u must use javascript for that.
$("#masthead .color-site-white").hover(function(){
$(this).css({background:'white'});
})
add these lines to your div
.top-strip color-site-white {
-webkit-transition: 0.2s;
-moz-transition: 0.2s;
-ms-transition: 0.2s;
transition: 0.2s;
}
.top-strip color-site-white:hover {
background-color: #whatever...
}

how to gradually turn the background opacity of a bootstrap navbar into a solid color

The effect that I'm trying to comprehend is used in the Start Bootstrap Grayscale Template.
This is a bootstrap 3.0 implementation.
As you scroll down, the nav area quickly but smoothly changes its color.
I'd like to bring this awesome feature into yamm's mega menu.
http://geedmo.github.io/yamm/
But before I can do that, I must comprehend the overall idea.
Could someone shed some light on this?
The styles that deal with the nav area is as follows;
.navbar {
margin-bottom: 0;
border-bottom: 1px solid rgba(255,255,255,.3);
text-transform: uppercase;
font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
background-color: #000;
}
.navbar-brand {
font-weight: 700;
}
.navbar-brand:focus {
outline: 0;
}
.navbar-custom a {
color: #fff;
}
.navbar-custom .nav li a {
-webkit-transition: background .3s ease-in-out;
-moz-transition: background .3s ease-in-out;
transition: background .3s ease-in-out;
}
.navbar-custom .nav li a:hover,
.navbar-custom .nav li a:focus,
.navbar-custom .nav li.active {
outline: 0;
background-color: rgba(255,255,255,.2);
}
.navbar-toggle {
padding: 4px 6px;
font-size: 16px;
color: #fff;
}
.navbar-toggle:focus,
.navbar-toggle:active {
outline: 0;
}
#media(min-width:767px) {
.navbar {
padding: 20px 0;
border-bottom: 0;
letter-spacing: 1px;
background: 0 0;
-webkit-transition: background .5s ease-in-out,padding .5s ease-in-out;
-moz-transition: background .5s ease-in-out,padding .5s ease-in-out;
transition: background .5s ease-in-out,padding .5s ease-in-out;
}
.top-nav-collapse {
padding: 0;
background-color: #000;
}
.navbar-custom.top-nav-collapse {
border-bottom: 1px solid rgba(255,255,255,.3);
}
}
I'm curious to know which sections are responsible for this effect.
Not necessarily what you are looking for, but you could try something like in this fiddle. If you look in the console while scrolling down, you will see the distance from the top as it changes. You can just check the distance and then simply change the class of the menu.
The JS would be something like:
$(window).scroll(function(){
var posTop = $(window).scrollTop() - $('.container').offset().top
console.log('from .container: '+posTop+' | from top of page: '+$(window).scrollTop());
}).trigger('scroll');
Edit: you edited the question and made it more specific, my answer doesn't really apply for what you're asking now.
Later edit: the effect seems to be done from JavaScript, as I suggested. If you look in greyscale.js you can find:
//jQuery to collapse the navbar on scroll
$(window).scroll(function() {
if ($(".navbar").offset().top > 50) {
$(".navbar-fixed-top").addClass("top-nav-collapse");
} else {
$(".navbar-fixed-top").removeClass("top-nav-collapse");
}
});
at the very top of the file. Basically it says that whenever a user scrolls, it checks whether it got 50px lower than the top. If it has, it changes the class of the nav to top-nav-collapse. The smoothing effect comes from CSS, however.

Why doesn't a CSS transition to the default style work?

I've been procrastinating by trying to make a fancier HTML checkbox, using Font Awesome for icons. I'm almost happy with this: (CodePen)
HTML
<input type="checkbox" id="cb"/>
<label for="cb">
<i class='icon-check-sign'></i>
</label>
CSS
#cb {
display: none;
}
#cb + label {
font-size: 64px;
color: #002b36; /* black */
transition: color 1s;
}
/* hover */
#cb + label:hover > i {
color: #268bd2; /* blue */
transition: color 1s;
}
/* checked */
#cb:checked + label > i {
color: #859900; /* green */
transition: color 1s;
}
/* checked + hover */
#cb:checked + label:hover > i {
color: #dc322f; /* red */
transition: color 1s;
}
(The colours and transition duration are exaggerated to make the issue more visible.)
My problem is that the colour changes smoothly when going from the default state to the hover state (the cursor is moved over the icon), from hover to checked (the icon is clicked), and from hover+checked to checked (the cursor is moved away). However, when going from hover back to default (the mouse cursor is moved away from an unchecked icon), the color doesn't transition but changes immediately.
Why does that happen and how could it be fixed? Bonus question: can this effect be somehow done without as much extra markup? (The <i> and the <label>.)
(I also suppose this would be more usable if I swapped between a checked and unchecked icon, but that seems like it would require chaining two transitions on different elements and I've no idea if that's even possible with CSS alone.)
You're missing a > i
#cb + label > i {
font-size: 32px;
color: #002b36; /* black */
transition: color 1s;
}
Updated CodePen
if you have a transtion in the :hover like this
something:hover{
transition: ...;
}
The transition will only apply when you hover so you need to put the transition in the default style for it to transition all states
like this
something{
color: red;
transition: all 200ms ease;
}
something:hover{
color: blue;
}
So in your case you need to add the following styles.
#cb + label i {
transition: color 1s;
}
solution
demo: http://jsfiddle.net/SuunK/2/
the markup:
<input type=checkbox id=cb hidden>
<label for=cb></label>
the style:
[for=cb] {
padding: 5px 16px;
position: relative;
border-radius: 4px;
background-color: black;
transition: background-color 1s;
}
[for=cb]:before,[for=cb]:after{
content:'';
position:absolute;
}
[for=cb]:before{
width: 6px;
height: 10px;
background: white;
-webkit-transform: rotateZ(-45deg);
left: 8px;
bottom: 6px;
}
[for=cb]:after{
width: 5px;
height: 16px;
background: white;
-webkit-transform: rotateZ(45deg);
right: 13px;
bottom: 5px;
}
[for=cb]:hover{
background-color: #268bd2; /* blue */
}
/* checked */
#cb:checked + label{
background-color: #859900; /* green */
}
/* checked + hover */
#cb:checked + label:hover{
background-color: #dc322f; /* red */
}

jQuery toggles active state

I'm implementing this toggles on my page http://www.creativusmouse.com/Hyperion/html/toggles.html and wanted to have the toggle button to remain orange when it's active. Please find bellow the CSS and jQuery code used.
I believe this is something easy to achieve. Hope someone could help me.
Thank you ;)
jQuery(window).load(function(){
$('.toggle-view li').click(function () {
var text = $(this).children('div.toggle-content');
if (text.is(':hidden')) {
text.slideDown('200');
$(this).children('span').html('<i class="icon-minus"></i>');
} else {
text.slideUp('200');
$(this).children('span').html('<i class="icon-plus"></i>');
}
});
});
/* ======================== CSS ======================== */
.toggle-view {
margin:0;
padding: 0;
list-style-type:none;
}
.toggle-view li {
margin:0px 0px 25px;
position:relative;
cursor:pointer;
display: block;
font-weight: bold;
text-decoration: none;
}
.toggle-view h2 {
font-size:12px;
text-transform:uppercase;
margin:0;
padding:4px 0 4px 40px;
}
.toggle-view span {
background: none repeat scroll 0 0 #80acb9;
color: #fff;
font-size: 12px;
padding: 2px 4px 2px 2px;
position: absolute;
left: 0px;
top: 0;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.toggle-view li:hover h2 {
}
.toggle-view li:hover span {
background: none repeat scroll 0 0;
background:#F63;
color:#fff;
}
.toggle-view .toggle-content {
box-sizing: content-box;
display:none;
padding:10px 35px;
}
.toggle-view ul.square, .toggle-view ul.circle, .toggle-view ul.disc {
margin-left:20px;
}
add another class to the span element.
in CSS add the class selector to the for the span, that is the same as the hover one:
.activetoggle, .toggle-view li:hover span {
background: none repeat scroll 0 0;
background:#F63;
color:#fff;
}
and in javascript add:
$(this).children('span').toggleClass('activetoggle');
I think this might work.
here is a little simplified illustration on jsfiddle
Update: I updated the jsfiddle with your markup and code, and I toggle the class now on the li element
$('.toggle-view li').click(function () {
var text = $(this).children('div.toggle-content');
if (text.is(':hidden')) {
text.slideDown('200');
$(this).children('span').html('<i class="icon-minus"></i>');
} else {
text.slideUp('200');
$(this).children('span').html('<i class="icon-plus"></i>');
}
$(this).toggleClass('activetoggle');
});
to simplify everything a little =) The CSS selector is now .activetoggle span.
jsfiddle

Resources