CSS Image hover works horizontally but not vertically - html

I currently am working a CSS navigation system on my client's website at http://cjcdigital.net/clients/andrea and while the top navigation has been working fine, I am unable to recreate the rollover effect on the vertical sidebar containing the social media buttons.
To achieve the top navigation effects I followed the steps at:
http://www.elated.com/articles/css-rollover-buttons/
With my navigation elements each being stacked top/bottom.
For the side navigation however, despite setting the image:hover to push the sprite to the left, the image hover property does not kick in at all.
Below is some code from the top nav, and below that is code form the side nav.
#headerMenu {width: 1200px;}
#headerMenu ul{display: inline;}
#headerMenu li a{top:334px; position:absolute;}
#magazine
{
display: block;
width: 112px;
height: 17px;
background: url("./images/magazine.gif") no-repeat 0 0;
left:160px;
}
#magazine:hover
{
background-position: 0 -17px;
}
#magazine span
{
position: absolute;
top: -999em;
}
Social Navigation
#facebook
{
display: block;
width: 149px;
height: 57px;
background: url("./images/facebook.gif") no-repeat 0 0;
}
#facebook:hover
{
background-position: -300 0;
}
#facebook span
{
position: absolute;
top: -999em;
}
Thanks in advance for any assistance

You haven't specified any units in your CSS declaration for #facebook:hover. You probably wanted to do something like:
#facebook:hover
{
background-position: -300px 0;
}

Related

Navigation Bar: Second level with full width

I created a navigation bar with a first and second level navigation. You can see the latest version here as a JSFiddle (maybe you have to increase the width of the frame containing the output to see the navigation bar with two levels).
At the moment, I have several issues with this navigation bar:
The width of the first level element "Menu1" should only be the width which it will need and not the width of the total width of the elements inside the second level navigation.
The second level navigation should be width 100% so the same as the yellow header and not only the width of the elements of the second level navigation bar.
So the navigation bar should look like the following image:
But how can this be achieved, especially the width of 100% of the second level navigation bar? I tried this CSS-Tricks: Full Browser Width Bars with "Using pseudo elements", because I did not want to have this definition globally on
html, body {
overflow-x: hidden;
}
Any help is highly appreciated!
Is this what you want http://jsfiddle.net/aytaxykf/5/
i added this ontop of your styling. so you can probably remove some of the rules you have there
.top-bar {
position: relative;
}
.top-bar-section {
height: 70px;
}
ul.sub-menu {
display: block;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: blue;
text-align:center;
}
ul.sub-menu li{
display: inline-block;
float: none;
}
.menu-center a {
position: relative;
}
.menu-center .active > a:before {
position: absolute;
bottom: 0;
left: 50%;
margin-left: -10px;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent lime transparent;
}

Images Over lapping my navigation bar

Code of navigation bar
ul {
position: fixed;
top: 0;
left: 0;
width: 100%;
overflow: hidden;
list-style-type: none;
background: black;
margin: 0;
padding: 0;
}
li {
float: left;
padding: 25px 25px;
cursor: pointer;
}
a {
text-decoration: none;
color: white;
font-size: large;
}
and code of image
.image {
position: relative;
left: 500px;
overflow: hidden;
So when I scroll text smoothly hides behind navigation bar. but the enter image description hereimage overlaps the navigation bar
right now on my right the div of 'similar questions' is also overlapping the bottom black div
You should set a z-index to your ul and make sure it is higher than what the other elements have.
You will need to add a z-index to the main navigation higher than the content scrolling. As mentioned.
But also you using position: relativeon the image, if you also set its parents position to relative as well thi sway the image will stay within the main contents wrapper, and scroll beneath the menu with the rest of the content.

How to make image/buttons stay in place when re-sizing web browser

This is my image-button for my website. http://puu.sh/cK7Sf/6309c39cdb.jpg When I re-size my browser it goes over here http://puu.sh/cK7VU/f17dafcc41.jpg
Here is my code
HTML
<div class="Nav">
<div id="buttons">
<div id="home_button"></div>
CSS
#home_button {
background-image: url("home.png");
background-repeat:no-repeat;
background-size: 100%;
width: 150px;
height: 60px;
position: absolute;
top: 196px;
left: 502px;
z-index: 10;
}
The reason is left: 502px;
You should center div id="buttons", for example like this:
.Nav {
display: flex;
}
#buttons {
margin: 0 auto;
}
#home_button {
background-image: url("home.png");
background-repeat:no-repeat;
background-size: 100%;
width: 150px;
height: 60px;
}
This will center #buttons inside .Nav and #home_button would be on the left
To have a dynamic website, you need to have flowing elements, not absolute elements.
http://www.w3schools.com/cssref/tryit.asp?filename=trycss_position_absolute
In this link you will see that the heading is fixed to the location because it is positioned absolute.
For a flowing element, as you want. Try this;
html - replace all 'a' within your buttons div with li's (As it is a list)
<ul>
<li id='HomeButton'><a href='#'></a></li> <!-- Duplicate this line with as many links as you want -->
</ul>
CSS
#buttons ul {
float: none;
clear: both;
}
#buttons li {
float: left;
}
#HomeButton {
background: url("home.png") no-repeat;
backgroound-size: 100%;
width: 150px;
height: 60px;
}
Also:
To make your code more efficient and cleaner to read, head to this link and view the bottom section 'Background shorthand' http://www.w3schools.com/css/css_background.asp - Shorthand coding is faster for both typing and reading.
eg.
background-image: x
background-repeat: x
is slower than
background: url("home.png") no-repeat;

Social icons won't work in mobile and in some tablets (Link doesn't work and they don't change image on hover)

I've created some social media icons and set them up using the following html and css. They're supposed to change to a different image upon hover and are also supposed to be linking to the various social media links. However, on some tablets and mobile, it doesn't change image upon hover and doesn't go anywhere when you click it. Here's the HTML and CSS for it. There's one at the top and bottom of the page. I'm having the issue with the one at the bottom in the footer area.
HTML:
<div class="social-media-holder socialtop">
<div title="Visit our Facebook page" class="social-facebook" onclick="window.open('http://www.facebook.com/ilovetennistoronto')"></div>
<div title="Visit our Twitter page" class="social-twitter" onclick="window.open('http://www.twitter.com/ilovetennisTO')"></div>
<div title="Visit our Google+ page" class="social-google" onclick="window.open('https://plus.google.com/u/1/b/117545117809252336887/117545117809252336887')"></div>
</div>
CSS:
.social-media-holder {
float: right;
margin: -18px -40px 0 0;
}
.socialtop {
top: -7px;
}
.social-facebook,
.social-google,
.social-twitter {
background-image: url('http://www.ilovetennis.ca/wp-content/themes/I-L-T-Theme/images/button_sprite_low.png');
background-repeat: no-repeat;
height: 32px;
margin: 2px;
width: 32px;
}
.social-facebook,
.social-google,
.social-twitter {
display: inline-block;
height: 25px;
vertical-align: top;
width: 25px;
}
.social-google {
background-position: -621px -71px;
}
.social-twitter {
background-position: -581px -71px;
}
.social-facebook {
background-position: -541px -71px;
}
.social-google:hover {
background-position: -621px -29px;
}
.social-twitter:hover {
background-position: -581px -29px;
}
.social-facebook:hover {
background-position: -541px -29px;
}
Can someone please help me out? I would really appreciate it. I've been trying to figure this out.
Tablet devices don't have a hover per say. You may have to use jQuery mobile to "fake" that effect when a user touches one of your icons.
As for why your page doesn't go anywhere when the user clicks... div elements shouldn't really have onclick events like this. Using anchor tags is much more sensible.
<div class="social-media-holder socialtop">
<a title="Visit our Facebook page" class="social-facebook" href="http://www.facebook.com/ilovetennistoronto" target="_blank">Facebook</a>
<a title="Visit our Twitter page" class="social-twitter" href="http://www.twitter.com/ilovetennisTO" target="_blank">Twitter</a>
<a title="Visit our Google+ page" class="social-google" href="https://plus.google.com/u/1/b/117545117809252336887/117545117809252336887" target="_blank">Google+</a>
</div>
And CSS
.social-media-holder {
float: right;
margin: -18px -40px 0 0;
}
.socialtop {
top: -7px;
}
.social-media-holder a {
background: url('http://www.ilovetennis.ca/wp-content/themes/I-L-T-Theme/images/button_sprite_low.png') no-repeat;
height: 32px;
width: 32px;
margin: 2px; /* with the display: block; float: left; below; this 2px margin will work properly now */
text-indent: -3000px; /* hides the text of the icons, and so people with screen readers can still see your social icons */
display: block;
float : left; /* please note this as with inline-block would cause white space with the anchor tags on separate lines.*/
height: 25px;
vertical-align: top;
width: 25px;
}
/* icons */
.social-google {
background-position: -621px -71px;
}
.social-twitter {
background-position: -581px -71px;
}
.social-facebook {
background-position: -541px -71px;
}
/* icons : hovers */
.social-google:hover {
background-position: -621px -29px;
}
.social-twitter:hover {
background-position: -581px -29px;
}
.social-facebook:hover {
background-position: -541px -29px;
}
Hope this helps (and works).
The problem is your div ".rt-logo-block" has a width of 100% which on small screens covers your social icons. Simply add a "float:left" on the .rt-logo-block selector for small screens and the issue is resolved
#media only screen and (max-width:650px) {
.rt-logo-block {
float:right
}
}
should do it.
Obviously you may need to play around with the max-width value depending on your needs
In the footer the same thing is occurring when the social media icons are being overlapped by the div ".rt-grid-4.rt-alpha" the solution is to add the following css to ".social-media-holder" for small screens:
#media only screen and (max-width:650px) {
.social-media-holder {
float: none;
text-align: right;
margin-right:0px;
right:0px;
}
}

Client added an image to WordPress header and not aligning properly

my client has added an image to their WordPress header. I am having difficulty (I'm still learning CSS) getting the image to align where we want it.
This is the site here
You can see the Options House graphic on the right. I want it to be to the right of the word "stocks" in the tagline. Help?
====Edits based upon suggestions below====
#Beardminator made a suggested answer, but this is what the site header looked like after including that code:
Relatively position that options_house div like so:
#options_house {
float: right;
position: relative;
top: 40px;
left: 52px;
}
And take off the overflow hidden from the header class.
Here is the 2 div which you should replace with this code:
.slogan {
color: #EBEBEB;
font-size: 17px;
left: 200px;
line-height: 25px;
position: absolute;
text-shadow: 0 2px 4px #0F243E;
top: 59px;
}
.logo_mmj, .logo_mmj:visited, .logo_mmj:hover, .logo_mmj:visited:hover {
background: url("../images/logo_marijuana.png") no-repeat scroll 0 0 transparent;
display: block;
float: right;
height: 95px;
position: absolute;
right: 0;
text-decoration: none;
top: 23px;
width: 392px;
}
You need to put the logo to the right, so the .logo_mmj should contain
right:0px;
Or if you use position:relative;
You can use like this:
.logo_mmj
{
position:relative;
float:right;
}
update:
The site you linked have very different logo that's why It only made it worse. You only need to adjust
.slogan left property. And add
to .logo_mmj div top:30px or much more.