Welcome to Micek Design, the personal portfolio and blog of Chris Micek. I am young freelance web and graphic designer based in Chicago, but working worldwide.

I like manhattans (the drink), star wars (the movie) and Apple (the company).

You can contact me at cmicek@gmail.com

What is RSS?

Colophon

Micek Design runs using the Wordpress Content Mangement System.

Logo and supporting elements are set using Aller. All other type is set in Georgia, with the body text using Verdana.

This site is compatible with all modern browsers. Note the use of 'modern.' Internet Explorer 6 is no longer a modern web browser, and is not being supported by my website design.

This site was designed and coded in November of 2008 using all Adobe Products. HTML/CSS and PHP were created using Dreamweaver 8.

Dynamic Width List Images using just HTML/CSS

02/20/09 Blog

In an article posted on Smashing Magazine today (Ask SM [CSS/JS]: Divs of Equal Height, Dealing with IE 6), the writer determined that the only solution to the following question is the use javascript/jquery.

Is it possible to create a list with CSS that has the text aligned to the right side, but on the left side has an image taking up the width of the remaining space?

That didn’t seem right to me, so I came up with a solution that used HTML/CSS and overlaying images. (Final Solution)

  1. Using CSS, I applied a repeating image of the line to each list item (<li>) (step 1)
  2. I wrapped the text of each list-item in a <div> and gave that div tag a white background: so that the line doesn’t cross through it. (step 2)
  3. I put an empty <span> tag at the beginning of the <div> and applied my gradient to that span. (step 3)
  4. Using Absolute positioning I moved the <span> 100px to the left (the width of the gradient image.) (step 4)

list-image1

There you go, tested in Firefox 3, Safari, IE6, and IE7

HTML

<ul>

<li>
<div><span></span>List Item Number One</div>
</li>

<li>
<div><span></span>Long, Multi Line List Item Long, Multi Line List Item Long, Multi Line List Item Long, Multi Line List Item</div>
</li>

<li>
<div><span></span>List Item Number Three</div>
</li>

</ul>

CSS

ul{
list-style:none;
width:60%;
}

li{
position:relative;
float:right;
width:100%;

text-align:right;
background:url(line.jpg) repeat-x;
background-position:0px 13px;
margin: 0 0 8px 0;
}

li span{
position:absolute;
height:100%;
width:100px;
top:0px;
left:-100px;
background:url(line-grad.jpg) no-repeat;
background-position:0px 13px;
}

li div{
font-weight:normal;
background:#fff;
margin-left:200px;
position:relative;
float:right;
}

Images

line (Basic Line)

line-grad1(Line Gradient)

Add a Comment

Qualitative ssl certificate for your protect.