我正在尝试创建一个List项目并在它们之间添加分隔符我尝试了所有内容但问题仍然存在。这是我希望我的列表菜单的图像: -
我正在使用的css和html代码是: -
HTML: -
<p class="Categories">Categories</p>
<div class="Rectangle"></div>
<div class="Categories_Box box1 box2">
<ul>
<li><a href="#" class="">Today</a></li>
<div class="line1"></div>
<li><a href="#" class="yest">Yesterday</a></li>
<li><a href="#" class="this_week">This Week</a></li>
<li><a href="#" class="last_week">Last Week</a></li>
<li><a href="#" class="last_month">Last Month</a></li>
</ul>
</div>
CSS: -
.Categories {
font-size: 29px;
font-family: "Exo";
color: rgb(237, 106, 61);
font-weight: bold;
line-height: 0.869;
position: absolute;
left: 227.937px;
top: 215px;
z-index: 31;
}
.Rectangle {
background-color: rgb(107, 107, 107);
position: absolute;
left: 231px;
top: 281px;
width: 194px;
height: 5px;
z-index: 29;
}
.Categories_Box ul{
position:absolute;
left: 0px;
top: 0px;
width: 1366px;
height: 768px;
z-index: 43;
list-style:none;
}
.yest, .this_week, .last_week, .last_month {
font-size: 21px;
font-family: "Exo";
text-decoration:none;
color: rgb(107, 107, 107);
font-weight: bold;
line-height: 0.86;
-moz-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
-webkit-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
-ms-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
position:relative;
left: -175px;
top: -641.112px;
z-index: 30;
}
.line1 {
font-size: 10px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
left: 345.85px;
top: 684.418px;
z-index: 100;
}
.box2 {
border-style: solid;
border-width: 1px;
border-color: rgb(217, 217, 217);
border-radius: 5px;
background-color: rgb(242, 242, 242);
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.36);
position: absolute;
left: 219px;
top: 229px;
width: 228px;
height: 498px;
z-index: 27;
}
.box1 {
border-radius: 5px;
background-color: rgb(255, 255, 255);
position: absolute;
left: 221px;
top: 230px;
width: 225px;
height: 498px;
z-index: 28;
}
编辑此代码后,我的前20名列表消失了,我甚至看不到菜单项。
请帮帮我
答案 0 :(得分:1)
您可以通过为列表项添加虚线边框底部来创建外观。举个简单的例子:
HTML:
<ul>
<li><a href='#'>Title</a></li>
<li><a href='#'>Element 1</a></li>
<li><a href='#'>Element 2</a></li>
<li><a href='#'>Element 3</a></li>
<li><a href='#'>Element 4</a></li>
</ul>
CSS:
ul{
list-style:none;
padding-left:10px;
padding-right:10px;
width:140px;
border:1px #eee solid;
border-radius:10px;
}
li{
border-bottom: 1px #ccc dashed;
}
a{
padding-top: 10px;
padding-bottom: 10px;
color: rgb(107, 107, 107);
text-decoration: none;
width: 100%;
height: 100%;
display: inline-block;
}
li:last-child{
border-bottom: none;
}
li:first-child{
border-bottom: solid grey;
}
li:first-child a{
color: rgb(237, 106, 61);
font-weight: bold;
font-size: 20px;
}
有关工作示例,请参阅https://jsfiddle.net/72vvksws/3/。
答案 1 :(得分:0)
感谢您在经过多次尝试后回复我,我解决了我的问题。正是z-index属性造成了问题。在以正确的顺序设置z-index属性之后,我能够在不使用border属性的情况下在列表项之间添加分隔符。这是代码: -
HTML: -
<p class="t20_files">Top 20 Files</p>
<div class="Rectangle1"></div>
<div class="Outside_box1 Inside_Box1">
<div class="Categories_Box1">
<ul>
<li><a href="#">Today</a></li>
<p class="line10">------------------------</p>
<li><a href="#">Yesterday</a></li>
<p class="line11">------------------------</p>
<li><a href="#">This Week</a></li>
<p class="line12">------------------------</p>
<li><a href="#">Last Week</a></li>
<p class="line13">------------------------</p>
<li><a href="#">This Month</a></li>
<p class="line14">------------------------</p>
<li><a href="#">Last Month</a></li>
</ul>
</div>
</div>
CSS: -
@import url(normalize.css);
html,body
{
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow-x: hidden;
background:url(../images/site_bg.png) no-repeat;
position: relative;
background-size: 100% 100%;
}
/*------------------------------Background---------------------------*/
/*-----------------------------Horizontal Menu Starts----------------*/
.head-menu {
background:url(img/menu_bg.png);
position: absolute;
left: 219px;
top: 117px;
width: 930px;
height: 81px;
}
.head-menu ul {
list-style: none;
position:relative;
}
.head-menu li a {
color: #FFFFFF;
line-height: 2.7;
line-width: 10px;
font-size: 17px;
text-align: left;
text-decoration: none;
text-transform: capitalize;
font-family: "Times New Roman";
color: rgb(255, 255, 255);
text-shadow: 0px 2px 1.96px rgba(0, 0, 0, 0.26);
-moz-transform: scale(1.39, 1.31);
-webkit-transform: scale(1.39, 1.31);
-ms-transform: scale(1.39, 1.31);
position: relative;
float: left;
left: -53px;
top: 2px;
}
.home {
margin-left:35px;
}
.allfiles {
margin-left:70px;
}
.ulpd_by_usrs {
margin-left:100px;
}
.upld_frm_mob {
margin-left:130px;
}
.contact {
margin-left:102px;
}
/*-----------------------------Horizontal Menu Ends----------------*/
/*--------------------------------------Top 20 Files Starts----------------------------*/
.Categories_Box1 ul {
position: relative;
list-style:none;
left: 0px;
top: 0px;
width: 1600px;
height: 1584px;
z-index:96;
}
.Categories_Box1 li a {
font-size: 22px;
font-family: "Exo";
position:relative;
text-decoration:none;
color: rgb(107, 107, 107);
font-weight: bold;
line-height: 2;
-moz-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
-webkit-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
-ms-transform: matrix( 0.76907888849934,0,0,0.58955579248353,0,0);
left: -34px;
top: 38px;
z-index:97;
}
.t20_files {
font-size: 29px;
font-family: "Exo";
color: rgb(237, 106, 61);
font-weight: bold;
line-height: 0.869;
position: absolute;
left: 227.937px;
top: 734px;
z-index:95;
}
.Rectangle1 {
background-color: rgb(107, 107, 107);
position: absolute;
left: 231px;
top: 799px;
width: 218px;
height: 5px;
z-index: 94;
}
.Outside_box1 {
border-style: solid;
border-width: 1px;
border-color: rgb(217, 217, 217);
border-radius: 5px;
background-color: rgb(242, 242, 242);
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.36);
position: absolute;
left: 219px;
top: 748px;
width: 210px;
height: 326px;
z-index: 92;
}
.Inside_Box1 {
border-radius: 5px;
background-color: rgb(255, 255, 255);
position: absolute;
left: 221px;
top: 749px;
width: 235px;
height: 326px;
z-index: 93;
}
.line10 {
font-size: 28.12px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
width:220px;
left: 8.2px;
top: -5.75px;
}
.line11 {
font-size: 28.12px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
width:220px;
left: 8.2px;
top: 35.75px;
}
.line12 {
font-size: 28.12px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
width:220px;
left: 8.2px;
top: 80.25px;
}
.line13 {
font-size: 28.12px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
width:220px;
left: 8.2px;
top: 123.75px;
}
.line14 {
font-size: 28.12px;
font-family: "Arial";
color: rgb(221, 221, 221);
line-height: 4.2;
position: absolute;
width:220px;
left: 8.2px;
top: 168.25px;
}
/*-----------------Top 20 Files Ends----------------------------*/
如果您有任何其他方法只使用一行而不是在每个列表项后使用p类标记,请发布它,以便我可以缩短我的代码。这是JS Fiddle链接: - JS Fiddle Link