How to make a single image, treated as three different images? - html

I was just going through a website code, and I saw an image for Social Networks link
When I see the website, I only see the top row of the images. It means the darker top three images.
The issue is when my mouse hovers over the facebook image, only facebook image becomes the light facebook image, and same happens for the other two links as well.
The code they have used is given below
<ul class="social-icons">
<li class="facebook">
<a title="Facebook" href="http://facebook.com/eclyptix">Facebook</a>
</li>
<li class="twitter">
<a title="Twitter" href="http://twitter.com/eclyptix">Twitter</a>
</li>
<li class="linkedin">
<a title="LinkedIn" href="http://linkedin.com/company/eclyptix">LinkedIn</a>
</li>
How is this done.
Your help is appreciated.
Thank you
Zeeshan

# Zeeshan; it's called sprite
check this article for more http://css-tricks.com/158-css-sprites/
check this example http://jsfiddle.net/sandeep/F4wpW/

This is CSS Sprite. Refer to article to make it happen.

You can set the background image position and crop it by setting width/height in the css file.
//HTML
<ul class="social-icons">
<li class="facebook">
<a title="Facebook" href="http://facebook.com/eclyptix"><img src="http://www.killersites.com/killerSites/resources/dot_clear.gif" width="30px"></a>
</li>
<li class="twitter">
<a title="Twitter" href="http://twitter.com/eclyptix"><img src="http://www.killersites.com/killerSites/resources/dot_clear.gif" width="30px"></a>
</li>
<li class="linkedin">
<a title="LinkedIn" href="http://linkedin.com/company/eclyptix"><img src="http://www.killersites.com/killerSites/resources/dot_clear.gif" width="30px"></a>
</li> </ul>
//CSS
.facebook{
background:url(http://i.stack.imgur.com/LNPd7.png) 0px 0px no-repeat;
width:30px;
height:30px;
}
.facebook:hover{
background:url(http://i.stack.imgur.com/LNPd7.png) 0px -30px no-repeat;
}
.twitter{
background:url(http://i.stack.imgur.com/LNPd7.png) -30px 0px no-repeat;
width:30px;
height:30px;
}
.twitter:hover{
background:url(http://i.stack.imgur.com/LNPd7.png) -30px -30px no-repeat;
}
.linkedin{
background:url(http://i.stack.imgur.com/LNPd7.png) -60px 0px no-repeat;
width:30px;
height:30px;
}
.linkedin:hover{
background:url(http://i.stack.imgur.com/LNPd7.png) -60px -30px no-repeat;
}
Here is the working example http://jsfiddle.net/kayadiker/uuKzQ/

Related

Position Image in line with text?

I am trying to get an image to sit directly next, to the left of a navigation bar item on bootstrap, I have almost got it, infact it works perfectly with small images, but as soon as I create a bigger image it messes up.
I have tried making the right of the image really small like 20px, but it makes no difference.
I haven't tried changing the width because I need the width to stay the same. I am not changing the height with size but with clipping, see the css below for more information on how I am doing it.
Unfortinately I can't place the image because stackoverflow says the format is not allowed, but here is the preview of how it looks:
http://image.prntscr.com/image/2445963b2dda43399a32c152675ceaa3.png
CSS:
#clip {
position: absolute;
clip: rect(0, 100px, 70px, 0);
/* clip: shape(top, right, bottom, left); NB 'rect' is the only available option */
}
HTML:
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle profile-image" data-toggle="dropdown">
<img id="clip" src="https://www.habbo.com.br/habbo-imaging/avatarimage?hb=img&figure=hr-828-52.hd-180-1.lg-280-1422.ch-3032-66-1408&action=wav&direction=2&head_direction=3&gesture=sml&size=m" />
Adam Sandler <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><i class="fa fa-cog"></i> Account</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out"></i> Sign-out</li>
</ul>
</li>
</ul>
I also use bootstraps css, but I wont paste all that here.
I have put all the code together on jsfiddle:
http://jsfiddle.net/ovjfeukc
I am not sure if the below is what you desire, but you can change the position: absolute; to display: inline-block;
#clip {
display: inline-block;
clip: rect(0, 100px, 70px, 0);
/* clip: shape(top, right, bottom, left); NB 'rect' is the only available option */
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle profile-image" data-toggle="dropdown">
<img id="clip" src="https://www.habbo.com.br/habbo-imaging/avatarimage?hb=img&figure=hr-828-52.hd-180-1.lg-280-1422.ch-3032-66-1408&action=wav&direction=2&head_direction=3&gesture=sml&size=m" /> Adam Sandler <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><i class="fa fa-cog"></i> Account</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out"></i> Sign-out</li>
</ul>
</li>
</ul>
Hope it helps
You also have padding from the .profile-image link tag that's causing the placement issue. You don't need absolute positioning on the image either. I just shrunk it with the height attribute, but you can fiddle around with that. Try these classes:
.profile-image {padding-top:0 !important; padding-bottom:0 !important;}
#clip {height:50px;}
http://jsfiddle.net/7845apm9/

How to have header on top of the slider

This is the current state:
and I want it like this:
I have done editing through photoshop to show my desired output. I have tried many things but i'm not successful.
This is the HTML:
<body>
<header>
<h1>Maxtergo - Guaranteed Perfect Product</h1>
<nav class='main-menu'>
<ul>
<li>
<a class='active' href='#'>Home</a>
</li>
<li>
<a href='#'>Portfolio</a>
</li>
<li>
<a href='#'>Services</a>
</li>
<li>
<a href='#'>Feature</a>
</li>
<li>
<a href='#'>Contact</a>
</li>
<li>
<a href='#'>Help</a>
</li>
</ul>
</nav>
</header>
<div id='slider'>
<div id='bannerscollection_zoominout_opportune'>
<div class='myloader'></div>
<!-- CONTENT -->
<ul class="bannerscollection_zoominout_list">
<li data-initialZoom="0.77" data-finalZoom="0.77" data-horizontalPosition="left" data-verticalPosition="center" data-text-id="#bannerscollection_zoominout_photoText2" ><img src="images/02_opportune.jpg" alt="" width="2500" height="1172" /></li>
<li data-initialZoom="0.77" data-finalZoom="0.77" data-horizontalPosition="left" data-verticalPosition="center" data-text-id="#bannerscollection_zoominout_photoText3" ><img src="images/03_opportune.jpg" alt="" width="2500" height="1172" /></li>
<li data-initialZoom="0.77" data-finalZoom="0.77" data-horizontalPosition="left" data-verticalPosition="center" data-text-id="#bannerscollection_zoominout_photoText4" ><img src="images/04_opportune.jpg" alt="" width="2500" height="1172" /></li>
<li data-initialZoom="0.77" data-finalZoom="0.77" data-horizontalPosition="left" data-verticalPosition="center" data-text-id="#bannerscollection_zoominout_photoText5" ><img src="images/05_opportune.jpg" alt="" width="2500" height="1172" /></li>
And no css is on the slider.
and this is header CSS:
header {
overflow: hidden;
padding: 25px 0px;
width: 960px;
margin: 0 auto; }
To make sure your header is shown above add z-index
header {
z-index: 99999;
overflow: hidden;
padding: 25px 0px;
width: 960px;
position:absolute;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
}
Firstly wrap up your both of your <header> and "slider" inside a
wrapper. Make sure that you have to provide it position "relative".
After that you have to go for making <header> as position absolute and
provide height and width as per your requirements. Then you must have to
add z-index to <header>. your <header> styles we will code here'll
look like this:
header {
position:absolute;
top:0;
bottom:auto;
left:0;
right:0;
margin:auto;
width:100%;
height:auto;
}

Background Sprites not showing in ie8

Im cross browser testing and i have come across an issue in ie8 that doesnt show my background social sprites which work in all other browsers.
here is my code:
<!-- Social Icon List -->
<ul class="social-icons">
<li style="text-align: center;"><a title="Follow us on Twitter" href="#"><span class="social"> </span></a></li>
<li style="text-align: center;"><a title="Follow us on facebook" href="#"><span class="social fbook"> </span></a></li>
<li style="text-align: center;"><a title="Follow us on Youtube play" href="#"><span class="social gplay"> </span></a></li>
</ul>
<p style="text-align: center;">#DecadeInTheCity</p>
<!-- Ends Social Icon List -->
and the css:
.social{
width:32px;
height:32px;
margin-top:7px;
background:url(../../uploads/2014/11/social-icons.png)no-repeat;
display:inline-block;
background-position:left top;
text-indent:-5000px;
}
.entry-content-wrapper div li {
text-indent: 0;
display: inline-block;
margin: 3px;
}
.fbook{
background-position:-32px;
}
.instagram{
background-position:-64px;
}
.gplay{
background-position:-96px;
}
is there anything i can do to make it display?
thanks, Ricky.
You can use inline style then it will work for you.
Like below -
<li style="text-align: center;"><a title="Follow us on Twitter" href="#"><span class="social" style="background:url('../../uploads/2014/11/social-icons.png') no-repeat;"> </span></a></li>

How to line up text in a unordered list of images

I have an unordered list of items where each item is an image followed by some text. I would like the text to line up exactly, but due to the icons being slightly different sizes, the text of each is not aligned. See the JSFiddle below for an example. You can see the "O" of Option is further to the left than the "R" of RSS feed.
What is the easiest way of achieving this? Is there a way to do this WITHOUT changing the images?
This is my HTML:
<ul class="dropdown-menu">
<li><a id="login" style="cursor:pointer;"><img src="http://www.w3schools.com/images/up.gif" /> Login</a></li>
<li><a id="upload" style="cursor:pointer;"><img src="http://static.bbci.co.uk/id/0.23.4/img/bbcid_orb_signin_dark.png" /> Upload a file</a></li>
<li><a id="option 3" style="cursor:pointer;"><img src="http://res2.windows.microsoft.com/resbox/en/windows%207/main/4f6cbd09-148c-4dd8-b1f2-48f232a2fd33_818.jpg"/>Option 3</a></li>
<li><a id="rss" id="rss" ><img src="http://www.w3schools.com/images/up.gif" /> RSS Feed</a></li>
<li><a id="about" style="cursor:pointer;"><img src="https://www.google.com/images/icons/product/googlemail-16.png" /> About</a></li>
</ul>
There is a JSFiddle here:
http://jsfiddle.net/9f1gxLv6/
Thanks,
Phil
If you're looking to space the icons and text evenly horizontally I recommend using the images as backgrounds instead of inline, then adding some padding:
#login {
background-image: url('http://www.w3schools.com/images/up.gif');
}
#upload {
background-image: url('http://static.bbci.co.uk/id/0.23.4/img/bbcid_orb_signin_dark.png');
}
#option_3 {
background-image: url('http://res2.windows.microsoft.com/resbox/en/windows%207/main/4f6cbd09-148c-4dd8-b1f2-48f232a2fd33_818.jpg');
}
#rss {
background-image: url('http://www.w3schools.com/images/up.gif');
}
#about {
background-image: url('https://www.google.com/images/icons/product/googlemail-16.png');
}
a {
display:inline-block;
padding: 2px 0 2px 30px;
background-repeat:no-repeat;
background-position: left center;
}
<ul class="dropdown-menu">
<li><a id="login" style="cursor:pointer;">Login</a>
</li>
<li><a id="upload" style="cursor:pointer;">Upload a file</a>
</li>
<li><a id="option_3" style="cursor:pointer;">Option 3</a>
</li>
<li><a id="rss" id="rss">RSS Feed</a>
</li>
<li><a id="about" style="cursor:pointer;">About</a>
</li>
</ul>

Navigation bar issues - steps forming

I have a problem with my navigation bar. When loading the page, sometimes it changes to look like its in steps however when you refresh it changes back to normal. I cant seem to find out what im doing wrong! Please help!!
Website is http://www.pearsonfoods.com.au
<div id="nav">
<a href="index.html" >
<div class="navBlock" style="color:red;"><p>Home</p>
</div>
</a>
<a href="about.html">
<div class="navBlock"><p>About us</p>
</div>
</a>
<a href="where.html">
<div class="navBlock"><p>Where we sell</p>
</div>
</a>
<a href="foods.html">
<div class="navBlock"><p>Our Foods</p>
</div>
</a>
<a href="contact.php">
<div class="navBlock"><p>Contact us</p>
</div>
</a>
</div>
Your markup is not well-formed. <a> is an "inline element" and <div> is a "block element". Block elements cannot exist within inline elements.
Your navigation list is better structured as a simple unordered list:
<ul>
<li>Home</li>
<li>About us</li>
<li>Where we sell</li>
</ul>
See? So much cleaner :)
Style each <li><a> as a block-flow element with display: block; (note this does not affect the inline/block semantics of elements, it's strictly a visual thing) and apply float: left; to the <li> elements.
html
<ul class="nav">
<li class="current">Home</li>
<li> About Us</li>
<li> Where we sell</li>
<li> Our Foods</li>
<li> Contact Us</li>
</ul>​
css
.nav {
width: 900px;
margin: 0 auto;
}
.nav li {
background-color: rgba(0, 0, 0, 0.72);
border-radius: 10px 10px 0px 0px;
width: 180px;
float:left;
}
.nav li a{
color:#fff;
text-decoration:none;
text-align:center;
line-height:50px;
display:block;
}
.nav li a:hover,.nav li.current a{
color:red;
}
Link to running example