-1

我想以最简单的方式重现以下内容(可能使用 a <ul>): 在此处输入图像描述

因此,我希望能够在此列表中添加任意数量的行,每一行由图片、描述和计数器组成。列表应该在一个圆角框中,并且行应该用线分隔。

有 CSS 技能的人可以帮我解决这个问题吗?

非常感谢!

4

4 回答 4

4

好吧,这是一种方法

HTML:

<ul>
    <li>
        <img src="http://www.placekitten.com/16/16">
        Item 1
        <span>1</span>
    </li>

    <!-- More list items -->
</ul>

CSS:

/* Container with border and rounded corners */
ul {
    border: 1px solid #ccc;
    width: 200px;

    /* Border radius for Chrome, Webkit and other good browsers */
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    -border-radius: 10px;
    border-radius: 10px;
}

/* Only add border to bottom of <li> */
li {
    padding: 10px;
    border-bottom: 1px solid #ccc;
}

/* Get rid of the last <li>'s bottom border to stop overlap with <ul>'s border */
/* :last-child works in IE7+ */
li:last-child {
    border-bottom: none;
}

/* Get the number and float it right */
span {
    float: right;
}
​
于 2012-04-21T12:13:00.640 回答
1

我正在为您开发JSfiddle

HTML:

<ul>
    <li><img src="http://ghickman.co.uk/images/sidebar/stackoverflow.png"/> <span>text</span> <span class="num">1</span></li>
   <li><img src="http://ghickman.co.uk/images/sidebar/stackoverflow.png"/> <span>text</span> <span class="num">1</span></li>
   <li><img src="http://ghickman.co.uk/images/sidebar/stackoverflow.png"/> <span>text</span> <span class="num">1</span></li>
</ul>

CSS:

ul {
    border-radius:10px;
    border:1px solid #DDD;
    margin:10px;
    width:200px;
}

li:last-child {
    padding:7px;
}

li:not(:last-child) {
    padding:7px;
    border-bottom:1px solid #DDD;
}

span.num {
    float:right;
}
img {
    width:20px;
}

span {
    float:none;
}
于 2012-04-21T12:10:21.103 回答
0

似乎您甚至没有尝试在 Google 上搜索“圆角”,但无论如何,您有 2 个选项:

  1. 使用 CSS 属性边框半径,但请注意它在 IE7 中不起作用
  2. 使用图像和background属性
于 2012-04-21T12:14:28.950 回答
-1

HTML:

<ul>
   <li>Event</li>
   <li>Journal</li>
   <li>Task</li>
</ul>

CSS:

ul { -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; background:#3d3d3; border:1px solid gray; width:400px; }
ul li { padding: 5px 5px 5px 20px; border-top:1px solid gray; }

这是JsFiddle

于 2012-04-21T12:16:19.900 回答