【发布时间】:2014-10-23 18:14:34
【问题描述】:
我有一些图像,我希望右上角和左下角有一半边框。我遇到的问题是:
问题1:我已经设法在所有四个角上切割边框,但不能切割左上角和右下角。下面的代码(我用的是KillaCam提供的这个fiddle,做了一点实验,结果四个角先出现,然后三个消失!:http://jsfiddle.net/3jo5btxd/
#div1 {
position: relative;
height: 100px;
width: 100px;
background-color: white;
border: 1px solid transparent;transition: border 2000ms ease 0s;
}
#div2 {
position: absolute;
top: -2px;
left: -2px;
height: 84px;
width: 84px;
background-color: #FFF;
border-radius: 15px;
padding: 10px;
}
问题 2 我已经有一个面板,它有一个使用 css 表格方法垂直居中的链接,它在悬停时也可见。当我将面板的代码与角边框结合起来时,我的垂直居中就会失控!我想这是因为我使用了额外的 div 作为边框,但我没有设法用:before 制作角落(在悬停时不起作用)。下面的 HTML 和 css 以及显示我想要制作的图像:
<ul class="img-list">
<li class="category_lists one-third column-block" '="">
<a href="http://kohphangan.smartsolutionpro.us/category/adventure/">
<img src="something.jpg"/>
<span class="text-content">
<span>Adventure</span>
</span>
</a>
</li>
<li class="category_lists one-third column-block" '="">
<a href="http://kohphangan.smartsolutionpro.us/category/beach-2/">
<img src="something2.jpg" />
<span class="text-content">
<span>Beach</span>
</span>
</a>
</li> </ul>
CSS:
/*css for the categories on home page*/
.img-list{margin:0;padding:0; list-style:none}
ul.img-list li {
display: inline-block;
height: 20em;
margin: 0;
position: relative;
}
.category_lists.one-third{width:33%; margin-left:0;}
.category_lists img{width:100%; height:auto;}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.text-content {
background: rgba(38,196,83,0.7);
color: white;
cursor: pointer;
display: table;
height: 7em;
left: 0;
position: absolute;
top: 0;
width: 100%;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
font-size:42px;
text-transform:uppercase;
font-family: 'Raleway', sans-serif; font-weight:300
}
ul.img-list li:hover span.text-content {
opacity: 1;
}
以及显示我想要制作的图片:http://tinypic.com/r/2gy5zk4/8。
如果我必须使用 javascript,我会,但我不是很擅长,所以指望 css 让它工作。非常感谢您的帮助。
【问题讨论】:
-
你想画那种边框的图片都是一样大小的吗?
-
@Sai,是的。宽度和高度应该相同。
标签: javascript jquery html css