Today we will learn together how to make a frequently used "CSS list with mixed graphics and text". First, analyze the characteristics of this list, then write HTML code, and finally apply CSS styles to achieve the final effect.
The effect of this example:
Author of this article: 52CSS.com Li Xiang If you want to reprint, please create a link to this site (http://www.52css.com/), and you are not allowed to change the content of the article at will, and retain the text of this copyright statement!
The top is the name of the column I love 52css and more, and then the bottom is divided into two blocks, one displays thumbnail images, and the other displays text links, both of which can be achieved through ul+li. With the above analysis, start the following HTML encoding:
Example Source Code
[www.downcodes.com] <div id="wrap">
<div class="list">
<div class="list_title"></div>
<ul class="list_pic"></ul>
<ul class="list_text"></ul>
</div>
</div>
Put all elements into the layer with id wrap, and set its border color to #e5f2f8. This is to make it look like it has a shadow effect.
Then create a layer list inside it, and create three layers inside the list, namely:
Example Source Code
[www.downcodes.com] list_title
list_pic
list_text
Let’s start writing HTML code in detail:
Example Source Code
[www.downcodes.com] <div id="wrap">
<div class="list">
<div class="list_title">
<h3>I love 52css</h3>
<span><a href="#">More</a></span>
</div>
<ul class="list_pic">
<li><a href="/u/info_img/2009-06/11/5394_quote.gif" /></a><span><a href="http://www.downcodes.com/">downcodes .com</a></span></li>
<li><a href="/u/info_img/2009-06/11/7852_quote.gif" /></a><span><a href="http://www.downcodes.com/default.asp ?cateID=9">DivCSS layout example</a></span></li>
<li><a href="/u/info_img/2009-06/11/8437_quote.gif" /></a><span><a href="http://www.downcodes.com/css_template/" >Template download</a></span></li>
<li><a href="/u/info_img/2009-06/11/3408_quote.gif" /></a><span><a href="http://www.downcodes.com/default.asp ?cateID=3">DivCSS Tutorial</a></span></li>
</ul>
<div class="clear"></div>
<ul class="list_text">
<li><span>[2007-09-11]</span>•<a href="http://www.downcodes.com/article.asp?id=813">Definition list dl creates a CSS list with pictures and texts Element</a></li>
<li><span>[2007-09-11]</span>•<a href="http://www.downcodes.com/article.asp?id=720">CSS web page layout example: with appropriate Tags create semantic tables</a></li>
<li><span>[2007-09-11]</span>•<a href="http://www.downcodes.com/article.asp?id=669">DivCSS layout example: a very practical picture Mixed text CSS list - rich in semantics</a></li>
<li><span>[2007-09-11]</span>•<a href="http://www.downcodes.com/article.asp?id=666">DivCSS layout example uses dl dt dd to Make a list</a></li>
<li><span>[2007-09-11]</span>•<a href="http://www.downcodes.com/article.asp?id=636">DivCSS layout example: three rows and one column top and bottom Fixed height intermediate adaptive</a></li>
</ul>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
Float h3 left in the list_title layer to create the title, float right to create more connections, and create ul+li pictures left floating in the list_pic layer;
Create ul+li in the list_text layer to create a news list;
At the very bottom, place a layer with class clear to clear the floats.
With the above foundation, start the following CSS coding:
Overall statement:
Example Source Code
[www.downcodes.com] * { margin:0; padding:0; font-size:12px; color:#666; list-style:none;}
a{ color:#666666; text-decoration:none;}
a:hover{ color:#2764b4; text-decoration:underline;}
Set the style of the entire layer wrap, the width is 450px, the top and bottom margins are 30px, the left and right sides are aligned horizontally, and the border is set to blue (here to increase the shadow effect)
Example Source Code
[www.downcodes.com] #wrap{ width:450px; margin:30px auto; border:1px solid #e5f2f8; overflow:hidden;}
.list{ width:448px; border:1px solid #a4a4a4;}
Style definition of the title part list_title:
Set the width to 426px, the top and bottom padding to 0, and the left and right margins to 10px
The column name h3 element floats to the left; the width is 300px;
Set the span element to float to the right with a width of 60px; align the text to the right and set the link
Example Source Code
[www.downcodes.com] .list_title{ width:426px; padding:0 10px; border:1px solid #fff; background:#f2e9da; height:22px; line-height:22px;}
.list_title h3{ float:left; width:300px;}
.list_title span{ float:right; width:60px; text-align:right;}
Style definition of picture layer list_pic:
First, use the ul list and set the width to 433px;
What needs attention is the setting of padding: padding:15px 0 0 15px;
(The reason why the right inner margin is set to 0 is because of the spacing problem of li, which improves the performance of the page. You can also set it to: padding: 15px 15px 0 15px; contrast effect)
li sets the size of the picture block to 94px, and the spacing margin: 0 14px 0 0;
The border color of the picture changes from blue to gray when the mouse is hovering;
Set link text style,
Convert span to block element. The links within the span are also converted to block elements, and the width and height are set to 94px and 20px respectively; the line spacing is set to 20px; and the text is aligned horizontally and centrally.
Example Source Code
[www.downcodes.com] .list_pic{width:433px; padding:15px 0 0 15px;}
.list_pic li{ display:inline; float:left; width:94px; margin:0 14px 0 0; overflow:hidden;}
.list_pic li img{ width:90px; height:70px;}
.list_pic li a img{ border:2px solid #b3deee;}
.list_pic li a:hover img{border:2px solid #ccc;}
.list_pic li span{ display:block; width:94px; height:20px; line-height:22px; text-align:center;}
.list_pic li span a{ display:block;}
Style definition of text layer list_text:
Define the news list through ul+li. It should be noted that the time span is floated to the right, and the text is written on the top border with a blue dotted line on the right, and the top margin is set to 10px;
Example Source Code
[www.downcodes.com] .list_text{width:426px; margin:10px; padding:10px 0 0; border-top:1px dotted #2764b4; }
.list_text li{ float:left; width:100%; line-height:22px;}
.list_text li span{ float:right; text-align:right;}
Finally, clear the float: .clear{ clear:both;}