css sprite : div h2 title image with ul li - css

I am using SpriteMe for my webpage and have code below. The problem is it show full sprite image instead of single image inside it.
<div class="white_box">
<div class="white_box_top_JS" style="background-image: url(http://www.jaredhirsch.com/coolrunnings/public_images/75a3bcd651/spriteme2.png); border: 2px solid red; background-position: -279.5px -10px; ">
<h2>Job Seekers</h2>
<ul>
<li>
Register
</li>
</ul>
</div>
</div>
I have read and followed <ul> Sprite Issue but can't get it.
http://jsfiddle.net/6TaQt/30/

It is best to stay away from inline style whenever possible. Additionally, the li element should receive the sprite, not the anchor. Here is a start on the relevant changes:
(also in a forked fiddle )
HTML:
<ul>
<li id="register">
Register
</li>
<li id="post">
Post resumes
</li>
<li id="find">
<a href="/find-jobs/" class="seo" >Find jobs</a>
</li>
<li id="get">
Get jobs by email
</li>
</ul>
CSS:
#register { width: 40px;
background-image: url(http://www.jaredhirsch.com/coolrunnings/public_images/75a3bcd651/spriteme2.png);
background-position: -1315px -6px; }
#post { width: 40px;
background-image: url(http://www.jaredhirsch.com/coolrunnings/public_images/75a3bcd651/spriteme2.png) ;
background-position: -1360px -6px; }
#find { width: 40px;
background-image: url(http://www.jaredhirsch.com/coolrunnings/public_images/75a3bcd651/spriteme2.png);
background-position: -685px -5px; }
#get { width: 40px;
background-image: url(http://www.jaredhirsch.com/coolrunnings/public_images/75a3bcd651/spriteme2.png);
background-position: -544px -6px; }

Related

z index is not working on image while using clip path on header element [duplicate]

This question already has answers here:
Prevent CSS clip-path from clipping children?
(3 answers)
Closed 1 year ago.
this is the screen shot of my problem.Thanks for this community to give me opportunity to have my problem to be solve, as I am facing problem in header section that my statistics image is not appearing on top of header (clip path). I need this image on top of clip path. I have searched a lot but nothing solve my problem. Plz look at this code and I have also attached screenshot to have you better idea what I am looking for.
Thanks in advance
.header {
background: linear-gradient(to right bottom, rgba($color-black, .85), rgba($color-black, .85)), url(../img/background.jpg);
background-size: cover;
background-position: center;
height: 95vh;
clip-path: polygon(0 0, 100% 0, 100% 15%, 60% 100%, 0 100%);
z-index: -10;
&__navigation {
background-color: $color-secondary;
}
&__flex {
display: flex;
align-items: flex-end;
}
&__textbox {
flex: 0 0 50%;
padding: 20vh 5vw 0 0;
&--text {
font-size: 1.6rem;
margin-bottom: 4rem;
color: $color-light;
}
}
&__photo {
flex: 1;
z-index: 10;
&--img {
display: block;
z-index: 10;
}
}
}
<!-- ================================= Header starts here ===========================-->
<header class="header" id="header">
<div class="header__navigation">
<div class="row">
<!-- ============= Navigation starts =============-->
<nav class="nav">
Olivlian
<ul class="nav__list js--nav__list">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Manufacturing
</li>
<li class="nav__item">
Packaging
</li>
<li class="nav__item">
Forms
</li>
<li class="nav__item">
Buy Now
</li>
</ul>
<i class="fas fa-bars js--menu"></i>
</nav>
<!-- ============= Navigation Ends =============-->
</div>
</div>
<div class="row">
<div class="header__flex">
<div class="header__textbox header__textbox--1">
<h1 class="heading-primary">
a vegan diet
</h1>
<p class="header__textbox--text">
Olive oil is a liquid fat obtained from olives, a traditional tree crop of the Mediterranian Basin, produced by pressing whole olives and extracting the oil. It is commonly used in cooking, for frying foods or as a salad dressing.
</p>
add to cart
book a table
</div>
<div class="header__photo">
<img src="img/6.jpg" alt="statistics" class="header__photo--img">
</div>
</div>
</div>
</header>
Thanks for the clarification.
You need to not clip the actual header element as that will clip everything within it.
Instead you can add a before pseudo element to the header which has the background and clip that. Then all the children of the header will remain unclipped so your statistics image will show.
Here's a simplified snippet to show the idea:
/*================================== Header Starts Here =====================================*/
.header {
position: relative;
height: 95vh;
width: 100vw;
}
.header::before {
content: '';
background-image: linear-gradient(rgba(0, 0, 0, .85), rgba(0, 0, 0, .85)), url(https://picsum.photos/id/1016/300/200);
background-size: cover;
background-position: center;
height: 95vh;
width: 100vw;
clip-path: polygon(0 0, 100% 0, 100% 15%, 60% 100%, 0 100%);
z-index: -1;
position: absolute;
top: 0;
left: 0;
display: inline-block;
}
header__navigation {
background-color: pink;
}
.header__flex {
display: flex;
align-items: flex-end;
}
.header__textbox {
flex: 0 0 50%;
padding: 20vh 5vw 0 0;
}
.header__textbox--text {
font-size: 1.6rem;
margin-bottom: 4rem;
color: lightblue;
}
.header__photo {
flex: 1;
z-index: 10;
}
.header__photo--img {
display: block;
z-index: 10;
}
<!-- ================================= Header starts here ===========================-->
<header class="header" id="header">
<div class="header__navigation">
<div class="row">
<!-- ============= Navigation starts =============-->
<nav class="nav">
Olivlian
<ul class="nav__list js--nav__list">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Manufacturing
</li>
<li class="nav__item">
Packaging
</li>
<li class="nav__item">
Forms
</li>
<li class="nav__item">
Buy Now
</li>
</ul>
<i class="fas fa-bars js--menu"></i>
</nav>
<!-- ============= Navigation Ends =============-->
</div>
</div>
<div class="row">
<div class="header__flex">
<div class="header__textbox header__textbox--1">
<h1 class="heading-primary">
a vegan diet
</h1>
<p class="header__textbox--text">
Olive oil is a liquid fat obtained from olives, a traditional tree crop of the Mediterranian Basin, produced by pressing whole olives and extracting the oil. It is commonly used in cooking, for frying foods or as a salad dressing.
</p>
add to cart
book a table
</div>
<div class="header__photo">
<img src="https://picsum.photos/id/1015/300/300" alt="statistics" class="header__photo--img">
</div>
</div>
</div>
</header>

can anyone help me for my css script,set height: 100% for sidebar(aside)

can anyone help me, why i can't set height: 100% for my aside (sidebar)??i have tried some ways to solve this, like set the height of html and body to 100%, or position to absolute, etc
but no one works for me
aside article > h1 {
text-align: center;
font-size: 24px;
padding: 25px 0;
}
aside:not(.nav){
background-color: rgba(0,0,0,0.9);
}
aside {
position: relative;
height: 100%;
width: 20%;
float: left;
color: #FFFFFF;
box-sizing: border-box;
}
this is my htmlc code for aside, something wrong with this???
<aside>
<article>
<h1>Yudistira S</h1>
<div class="header">
<img src="space.png" width="50" height="50"/>
<div class="clear"></div>
<p>Yudistira</p>
<p>Last Login : 2 Weeks Ago</p>
</div>
<div class="nav">
<ul>
<li>Dashboard</li>
<li class="navaside">UI Element
<ul>
<li>Tabs and Panels</li>
<li>Notification</li>
<li>Pprogressbars</li>
<li>Button</li>
<li>Icons</li>
<li>Wizard</li>
<li>Typography</li>
<li>Grid</li>
</ul>
</li>
<li class="navaside satu">Extra Pages
<ul>
<li>Invoice</li>
<li>Pricing</li>
<li>Component</li>
<li>Social</li>
<li>Messages and Tasks</li>
</ul>
</li>
</article>
</aside>
To assign a height equal to window size use the vh(view height)unit instead .
height:100vh;

Attach button next to side menu

I am using the Simple Side Nav: http://startbootstrap.com/template-overviews/simple-sidebar/
I want to attach a button next to side of this Nav, on the Right Side which I will be using to hide and show the Nav Bar.
I have created a JSFiddle: https://jsfiddle.net/4q08khy1/
This button is the position i want it to be, as you can see in the image:
But it is hiding behind the Content Part of the page, is there a way to fix this?
my Left Nav:
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Start Bootstrap
</a>
</li>
<li>
Dashboard
</li>
<li>
Shortcuts
</li>
<li>
Overview
</li>
<li>
Events
</li>
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
</ul>
<span> << </span>
</div>
and Style on toggle
<style>
.toggle {
background: #1ABC9C;
color: #eee;
position: absolute;
width: 50px;
height: 50px;
line-height: 50px;
text-align: center;
right: -50px;
top: 18px;
box-shadow: 5px 0 0 rgba(0,0,0,0.1);
z-index: 5000;
}
</style>
Try adding following CSS to your code:
a#menu-toggle {
margin: -25px 0 0 -36px;
}

Navigation bar center position

I am currently working with a bottom navigation bar for a test site. The problem is that the navigation bar does not center properly. I have added the .left attribute to keep each block list beside each other. How can I get this bottom navigation bar to center automatically(no matter the amount of lists added)? Example
CSS related to bottom navigation
<style>
.bottomnavControls {
padding-top:10px;
padding-bottom:10px;
padding-right:0;
text-decoration:none;
list-style:none;
}
#footer {
position: absolute;
width: 100%;
bottom: 0;
background: #7a7a7a;
border-bottom: 15px solid #000;
}
.left {
float: left;
}
.right {
float: right;
}
</style>
HTML
<div id="footer">
<div class="bottomNav">
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Home</b></li>
<li>Login</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Category</b></li>
<li>Games</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>About</b></li>
<li>Who We Are</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Links</b></li>
<li>Google</li>
</ul>
<ul class="bottomnavControls left">
<li style="padding-bottom:5px;"><b>Other Stuff</b></li>
<li>Stuff</li>
</ul>
</div>
</div>
My current Bottom navigation:
My desired outcome:
Instead of float, you should use display: inline-block here. This way, you can easily center them by putting text-align: center on the container.
.bottomNav { text-align: center; }
.bottomnavControls { display: inline-block; }
and remove left class.
Note: display: inline-block works fine in modern browsers, but it needs a hack in IE7.

Link Inside <li> No Working

Pretty simple nut I'm trying to crack. I'm doing image rollovers with CSS only. When I plugged in my a href link, it just does not work. By not work I mean, it does not act like it's a link and as a result you cannon click through to the page. Figuring it has something to do with the <li> but I can't figure out what. Here's my HTML and CSS:
CSS
ul.navigation,
ul.navigation ul {
margin: 25px 0 0 0;
}
ul.navigation li {
list-style-type: none;
margin:15px;
}
.AboutUsNav{
display: block;
width: 159px;
height: 54px;
background: url('../images/N_About_Us.png') bottom;
text-indent: -99999px;
}
.AboutUsNav:hover {
background-position: 0 0;
}
HTML
<div>
<ul class="navigation">
<li class="AboutUsNav">About Phin &amp Phebes Ice Cream</li>
<li class="FlavorsNav">Ice Cream Flavors</li>
<li class="WheretoBuyNav">Where to Buy Our Ice Cream</li>
<li class="WholesaleNav">Wholesale Orders Ice Cream</li>
<li class="ContactUsNav">Contact Phin & Phebes Ice Cream</li>
<li>about</li>
</ul>
</div>
Your .AboutUsNav has text-indent: -99999px;, pulling the a outside of the clickable viewport.
You probably want to put the negative text-indent on the a itself, and then set the a element to display: block; width: 100%; height: 100%, depending on your circumstances.
don't apply the text-indent and background to the list - do it to the link instead.
Example:
<div id=​"main_nav">
<li class="home">
Home
</li>
<li class="news">
News
</li>
</div>
CSS:
#main_nav a {
background-image:url();
}
#main_nav .home a {
width: 82px;
background-position: 0px 0px;
}
#main_nav .news a {
width: 85px;
background-position: 82px 0px;
}
thank you for your help. I tried the approach you both recommended. I think this definitely works under certain circumstances. For me, my background image just wasn't showing up but the links were working.
I ended up solving this problem by leaving the CSS the same but changing the HTML markup as so:
<div>
<ul class="navigation">
<li><a class="AboutUsNav" href="/about">About Phin & Phebes Ice Cream</a></li>
<li><a class="FlavorsNav" href="/flavors">Phin & Phebes Flavors</a></li>
<li><a class="WheretoBuyNav" href="/buy">Where to Buy Phin & Phebes Ice Cream</a></li>
<li><a class="WholesaleNav" href="/wholesale">Wholesale Orders Ice Creamf</a></li>
<li><a class="ContactUsNav" href="/contact">Contact Phin & Phebes Ice Cream</a></li>
</ul>
I was working off this demo, which didn't include an unordered list: http://kyleschaeffer.com/best-practices/pure-css-image-hover/

Resources