CSS Hover Option - html

I learn and use css and css3 around 2 years but i dont know 1 thing and i cant find a really good answer or fix for this.
So here is an example :
I created a div and inside this div we have a link (its a button).
When i hover my mouse on the div this div will change the bg-color but the link not because im above the div... So when im above the div this div and the link too will change the color or background this is what i need... But how to do it ? I never used this but now i think i'll need this for my next work :))
Thank you very much!

It's very easy to achieve using css: (working jsFiddle)
HTML:
<div class="container">
<a class="button">some text</a>
</div>
CSS:
.container:hover{
background-color:red;
}
.container:hover .button{ // selector for .button which is in a hovered .container
background-color:blue;
}

Try this:
<div id="test">
A link
</div>
CSS :
div#test:hover {
background-color: red;
}
div#test:hover a {
background-color: red;
}

What you're asking is the following CSS selector:
div:hover a{
/* your styles here */
}
Demo here

Hope this demo link will work for you.
*{
padding:0;
margin:0;
}
body {
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#000;
padding:20px;
background-color:#F2F2F2;
}
ul, li, ol {
list-style-type:none;
}
.wrapper {
width:95%;
padding:10px;
overflow:hidden;
height:100%;
margin:0 auto;
border:1px solid green;
}
.spacer {
clear:both;
font-size:0;
line-height:0;
height:0;
}
.wrapper:hover {
background-color:#999999;
cursor:pointer;
}
.btmoOne {
width:170px;
margin:0 auto;
height:20px;
background-color:#FF0000;
padding:10px;
}
.wrapper:hover .btmoOne {
background-color:#006600;
}

Related

Horizontally centering div and span with input child

I need this input field to prepend a # before the hex colour code, like so, as well as horizontally center both the div and the span containers:
<div id="color_wrapper">
<span>#<input type="text" value="ffffff"></span>
</div>
When I try with the following css:
html, body{
margin:0;
padding:0;
font-size:22px;
color:#fff
}
#color_wrapper{
border: none;
background-color:#444;
text-align:center;
}
span, input {
border: none;
}
input{
outline:none;
width:85px;
background-color:transparent;
font-size:inherit;
color:inherit;
display:inherit;
}
I achieve limited success, in that the hash is at the start and the span and input seem to be centered. The problem occurs when I attempt to set the width of the div, and though the width is set, it snaps back to the left.
So, how can I center the div and the span, while also being able to change the div's width?
Here's a fiddle with the code.
Just specify margin: 0 auto for your div.
html body{
margin:0;
padding:0;
font-size:22px;
color:#fff
}
#color_wrapper{
width:300px;
border: none;
background-color:#444444;
text-align:center;
margin:0 auto;
}
span, input {
border: none;
}
input{
outline:none;
width:85px;
background-color:transparent;
font-size:inherit;
color:inherit;
display:inherit;
}
<div id="color_wrapper">
<span>#<input type="text" value="ffffff"></span>
</div>
Hope it helps :)
Try this
span,input
{
align:center;
}
Hope it helps :-)

IMG won't hover

As you can see by my code, I am creating several different links in the shape of a circle, these links have an image, however when you hover the image, I want it to change the image to something else.
However when I try to hover it will not work? :S
CSS:
.Row {
width:16%;
height:250px;
text-align:center;
margin-top:25px;
margin-left:130px;
float:left;
display:block;
border:0px solid red;
overflow:hidden;
}
.Google {
width:240px;
height:240px;
text-align:center;
border:5px solid white;
border-radius:300px;
margin:auto;
background-image:url("img/googlet.png");
}
.Google:hover {
background-image:url("img/outlook.png");
}
HTML:
<div class="Row">
<div class="Google"></div>
</div>
You can block a tag with a {display:block;}
than write css for hover like following.
a:hover .Google {background-image:url("img/outlook.png");}

CSS border differences between browsers

I'm making a dropdown menu in pure CSS and I'm encountering some difficulties making the dropdown look the same in every browser.
I've tried everything I can think of - setting margins to zero, setting padding to zero... and nothing seems to work.
http://jsfiddle.net/mf9cS/
Safari renders it perfectly:
Firefox has a mysterious gap between the title and the dropdown:
And Chrome is missing one pixel out of the border on the top right concave corner:
CSS:
.container {
position:absolute;
top:50px;
left:50px;
margin:0px;
}
.title {
position:relative;
display:inline-block;
height:25px;
overflow:hidden;
font-size:15pt;
padding:0px;
padding-top:1px;
margin:0px;
}
.title:hover {
height:200px;
}
.title:hover > .links {
width:150px;
}
body {
font-size:14pt;
}
.links {
width:0px;
border:1px solid grey;
visibility:hidden;
padding-top:0px;
margin-top:0px;
}
.titletext {
margin-left:0px;
margin-top:0px;
height:25px;
margin-bottom:0px;
}
.title:hover > .titletext {
border:1px solid grey;
border-bottom:1px solid white;
}
.title:hover > .links {
visibility:visible;
}
a {
text-decoration:none;
color:grey;
width:150px;
display:block;
}
a:hover {
background-color:purple;
}
HTML:
<html>
<body>
<div class="container">
<div class="title">
<span class="titletext">
This is a test
</span>
<div class="links">
Link 1
Link 2
This is the third link
</div>
</div>
</div>
</body>
</html>
Problem is your white border of title span element. All browsers are rendering border different way. In chrome and firefox that white border is touching to end of that element where you see white space at corner. Set border radius to 2px it the space will go away. I'm sure but here is the demo.
`border-bottom-right-radius:2px`
http://jsfiddle.net/mf9cS/3/

Simple menu. CSS not working in IE7

I have the following menu. Seems to work in all browser but not IE6 or IE7. What is causing the problem and How can i fix that.
Check working example at http://jsfiddle.net/2ysCC/
#menu_wrap {
margin-top:20px auto 0 auto;
padding:0;
width:780px;
height:40px;
list-style-type:none;
}
.button a {
cursor:pointer;
text-align:center;
font:13px/100% Arial, Helvetica, sans-serif;
font-weight:bold;
position:relative;
min-width:50px;
height:20px;
float:left;
padding:10px;
padding-right:0;
text-decoration:none;
}
.Red, .Red .button a {
color:#faddde;
background: #ed1c24;
}
.button:last-child a {
float:left;
border:none;
}
<ul id="menu_wrap" class="Red">
<li class="button">Home</li>
<li class="button">portfolio</li>
<li class="button">Latest</li>
</ul>
This is how it looks in IE7
Add 'display: inline;' to your 'li'.
#menu_wrap .button {
display: inline;
}
Here is an article describing the bug in further detail: http://css-tricks.com/501-prevent-menu-stepdown/
Float the li tags instead of the a tags:
.button {
float: left;
}
JSFiddle
Try to remove position: relative and make it float: left
Use this CSS, float left element <LI>
li.button{
float: left;
}

CSS layout acting very weird and not positioning the elements where it should

The elements aren't positioning themselves as I want them to. I want the picture to be 20px away from the left, why is the logos div so thin? :S Also why is the topuserbar div going under? There seems to be no reason.
Here is the CSS and HTML. It's not rocket science, so that's extra frustrating because it shouldn't be rendering like this.
#header
{
border:1px solid red;
background-image: url('images/headerBackground.png');
background-repeat:repeat;
width:auto;
}
#logo
{
border:1px solid red;
display:inline;
margin-left:35px;
}
#topuserbar
{
border:1px solid red;
font-family:Georgia;
font-size:large;
float:right;
margin-right:50px;
}
#topuserbar ul
{
}
#topuserbar li
{
display:inline;
margin-left:10px;
color:#fff;
}
#topuserbar .helpicon
{
margin:0;
padding:0;
position:relative;
top:5px;
left:3px;
}
#topuserbar a
{
color:#fff;
}
#topuserbar a:hover
{
color:Yellow;
}
<body>
<div id="header">
<div id="logo">
<img src="../../Content/images/cumaviLogo.png" alt="Cumavi.com - Compras y ventas online en Bolivia!" />
</div>
<div id="topuserbar">
<ul>
<li>Bienvenidos, <span class="userSalute">Sergio!</span></li>
<li>Mis Anuncios</li>
<li>Perfil</li>
<li>Ayuda<img class="helpicon" src="../../Content/images/helpIcon.png" alt="Help icon." width="20" height="20"/></li>
<li>Cerrar Sesion</li>
</ul>
</div>
</div>
</body>
EDIT: What the heck? Opera and Firefox render things differently. I knew there were browser inconsistencies but for thing as simple as this?! Can a pro please let me know what's causing this?
I would give the header a specified height, take display:inline off of your logo div,and maybe make the logo div float:left;
For the first question should this solve it:
#logo
{
border:1px solid red;
display:inline;
margin-left:20px;
}
Im not sure if I understood you!
Try this:
#logo
{
border:1px solid red;
display:inline;
margin-left:20px;
height: 75px;
width:140px
}
adjust the height and width to your liking...
Got it:
This is how you stop to Chrome push your div under:
#topuserbar ul
{
margin:0px;
}
Worked fine for me!
Tell me if it does what you want!