CSS: How to make background color around text not flush to the text?
Tags: css,menu,background,hover
Problem :
I am new to CSS and website design. See the menu on the left on this page: When you hover over a menu element the background around the text becomes white but I would like the entire row and a little bit over and under the text to become white too, similar to the top menus. Here's the code I have:
.child-sidebar-menu
{
background-color: #DEDEDE;
}
.advanced-sidebar-menu ul li a{
text-decoration: none;
color: black;
border-bottom: 0px;
}
.advanced-sidebar-menu ul li a:hover{
text-decoration: none;
border-bottom: 0px;
}
.advanced-sidebar-menu li > ul li a:hover
{
color: black;
background-color: white;
}
.advanced-sidebar-menu ul ul li a{
font-weight: normal;
font-size: 100%;
border-bottom: 0px;
}
.advanced-sidebar-menu ul{
margin: 0 0 0 0px;
list-style: none;
list-style-type: none;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
border-bottom: 0px;
line-height: 200%;
}
.advanced-sidebar-menu ul li{
list-style:none;
list-style-type: none;
border-bottom: 0px;
}
.advanced-sidebar-menu li.current_page_item{
list-style-type: none;
border-bottom: 0px;
}
.advanced-sidebar-menu li.current_page_item a{
font-weight: bold;
border-bottom: 0px;
}
Any easy way to do this? Does it have to do with border and margin?
Thank you.
Solution :
Check this JSFiddle : http://jsfiddle.net/D5sdT/
The key points are :
- Make
<a>
tagdisplay : block
. This will allow<a>
to occupy complete horizontal space asli
- Remove
padding
andmargin
from<li>
. Instead give the same to<a>
.
CSS Howto..
Are you sure the html you write is correct ? there's a missing closing > here : " <div class=\"col-lg-3\" " + Also you might want to write like this...
You can use localStorage, or a browser embedded database, like IndexedDB or WebSQL. These will store data inside your browser, so it wont be shared with anyone.
you need to change z-index to 0 for icon-box class to achieve what you are looking for. For instance, .icon-box.aboutme h2, .icon-box.home h2, .icon-box.portfolio h2, .icon-box.blog h2, .icon-box.contact h2{ z-index:0;...
Based on your image, you can realize the layout by using the the following HTML: <div class="contentpart"> <a href="#"> <img src="http://placehold.it/300x200"> </a> Donec adipiscing, lorem non euismod venenatis... </div> and...
Update Since the OP wants to use the flex property for creating his colummns, here's the updated code (the html structure is same as my previous answer, just the css...
Something like this maybe? @media only screen and (max-width: 460px) { /* Force table to not be like tables anymore */ table, th, tbody, td, thead { display: block; width:...
Two things to consider: Transitions interpolate smoothly (well, according to the easing function) between keyframes. If you do not specify an attribute at a keyframe, it will interpolate without interruption...
You might be looking for the overflow:hidden; property. http://jsfiddle.net/R6DKg/5/...
I think the easiest way would be to use something like: css: .progress { position:relative; width: 100px; height: 100px; } .progressUnder { position: absolute; width: 100%; height: 100%; background-image: url('backgroundUnder.jpg');...
Besides CSS style, the problem you have is you've added a row class surrounding every post. Say you want to display three posts in each row, do it like this:...
You should consider making two different pictures, one normal and one with the background you want. An other option would be a container div ( not a good idea for...
I may be misunderstanding a critical piece to this, but since you're using SASS, could you simply use: #some-custom-area { @import "path/to/bootstrap-result.css"; } That is, take the Bootstrap CSS framework...
The best thing to do is create a class disabled in css, in this way you separate the presentation of logic. Sample CSS .shopcart{ background:url(/static/images/cart2.png) no-repeat; border:none; background-size:100% 100%; width:57px;...
You can't via any kind of simple selector. You could filter the element's parent list based on position, though: var fixedp = $('#IAmTheTarget').parents().filter( function() { return $(this).css('position') == 'fixed'; }...
This can easily be achieved with flexbox by simply removing all of the positioning from #profileContainer and adding the following rules to body: display: flex; justify-content: center; align-items: center; min-height:...
As typical website contains multiple css, java script and image files,causing browser to request multiple http requests. By using sprite it causes less http requests (good for webserver and client/user),...
$('#addButton').on('click', function( event ) { var searchedValue = $('#search_term').val(); var divHolder = $('.selectedStuff'); divHolder.append(searchedValue + '<br>').css({ 'background-color': 'yellow', 'margin-top': '50px' }); }); ...
Great question. We're working on CSS/JS editing in the split panel view within Divshot and it should be available very soon. I'll update this post when it's released.
The best way to do what you are after is to target only the anchor that is being clicked. To do that you can use $(this). Here is what the...
You want the nth-child(n) selector. Basically you put the number you want where n is, and it will get that element. $('#list li:nth-child(2)')...... This gets the 2nd li element inside...
How to vertically align in the middle a clickable image (between ) inside a div in a responsive manner?
Use like this <div class="accounts"> <a href="LinkA" target="_blank"><img src="Vendors/Images/GithubLogo.png" alt="Github"></a> </div> <div class="accounts"> <a href="LinkB" target="_blank"><img src="Vendors/Images/SOLogo.png" alt="Stack Overflow"></a> </div> ...
The easiest solution would be to wrap the whole thing in a parent and address the structure via that. .container > ul > li > a { font-weight: bold; font-size:...
Typically this kind of work is done by using the href of the anchor tag so that it can gracefully degrade in a non-javascript environment. Secondly, rather than passing the...
.nb_item { display:inline-block; width:auto; padding:0px 10px; color:#FFFFFF; margin:auto; text-align:center; } Instead of giving a width of 12.5%, give the width:auto, and then add a padding. and as far as cramping...
I think, I know what you need. Research please, @media screen, @media print, @media all ...
You should be able to control the position of the asterisk with position:relative and top:...px. Something like : label.control-label.required:before { color: red; content: "*"; font-size: 20px; position:relative; top:6px; font-family: arial;...
A solution to your problem would be to create a div with an absolute position. You could then align it to the center and to the bottom. Here some example...
You can add a border to YUI2 grids by adding styles to the yui-u class .yui-u { border: 1px solid black; } However, borders don't play very nice with YUI2...
As mentioned in Willem Van Bockstal answer to a similar problem, you could use table-like behaviour in CSS. First Give the list element a class and then make it a...
I have created an example here: http://jsfiddle.net/D26Hj/1/. It just needs an app logo and star sprite image. I have drawn up a star sprite image and quickly made a fake...