Share a CSS style that shows a list of articles

Source: Internet
Author: User

Recently in helping a friend to deal with a Web site front-end display of the list of articles, one of the alternative ideas, is now sorted out for the needs of friends reference and their own memo.

  1. The display effect is: the title is left aligned and the date is right-aligned.
  2. The middle of the title and date is replaced by a regular origin ("."), which shows the effect as shown.

As for the 1th requirement, it is easy to achieve, the date display of the East, plus "float:right" basically done.

But the 2nd requirement: The middle shows the origin of this tried a lot of ways:

For example, the background when returning data, based on the title text length auto-complement the origin string returned to the front-end display.

Or at the front end by JS to calculate the character length and then filled.

But the effect of the final display is not ideal.

Then, suddenly think, why not drop this "small origin" as the background of each item and in the horizontal repeating display (repeat-x), so that the title and date directly on the display. After trying, really OK, the following paste the solution of the CSS code for your reference.

. Data ul{List-style:None;Margin-top:5px;}. Data ul Li{Height:30px;}. List{margin:0px 10px 20px;text-align: Left;}. List Li{width:100%;background:URL (imgs/list_line_point.jpg) repeat-x;font-size:1.2em;margin:5px 0px 5px 0px;}. List Li Span.left{Background-color:#e3e3e3;padding:0px 13px 0px 13px;}. List Li Span.right{float: Right;text-align: Right;Background-color:#e3e3e3;padding:0px 13px 0px 13px;}

By the way, the HTML used by the front end:

<Divclass= "Data"ID= "Data_list">    <ulID= "Data_list_ul"class= "List">            <Li><ahref= "/front/articledetail/faf248f0-bce7-4b76-8ddf-14e728021b76"Target= "_blank">                <spanclass= "Left">Australian player wins Chinese amateur Open men's Championship</span>                 <spanclass= "Right">2014-11-17</span></a>            </Li>            <Li><ahref= "/front/articledetail/426396fc-66b0-4853-9c53-2ac973ee9c77"Target= "_blank">                <spanclass= "Left">The first amateur champion of the Chinese race was born</span>                 <spanclass= "Right">2014-11-17</span></a>            </Li>          </ul></Div>

Interface display effect, see http://www.cagr.cn/Front/News.

PostScript, I am not good at the front end, just knows, you crossing if feel cumbersome, but also hope to tap.

Share a CSS style that shows a list of articles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.