css border-left 50%height [英] css border-left 50% height

查看:132
本文介绍了css border-left 50%height的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让div的左边框只显示div的一半。同样我想做到我的右边界,但应该设置从div的底部到div的中间。如何实现?

I want the left border of my div to show only to the half of the div. The same I would like to do to my right border but is should be set from the bottom of the div to the middle of the div. How can I achieve it?

推荐答案

好问题。

如果你可以设置你的div 位置 relative ,是使用绝对定位,1像素宽 div 。未完全测试,但此工作:

The only thing that comes to mind, if you can set your div's position to relative, is to use an absolutely positioned, 1 pixel wide div. Not thoroughly tested but this should work:

<div style='width: 1px; top: 0px; bottom: 50%; left: 0px; 
            background-color: blue; overflow: hidden'>
 &nbsp;
</div>

您会在右侧执行相同操作,将

You'd do the same on the right hand side, replacing the left property by right.

请记住,周围的 div 需要 position:relative 才能正常工作。我不确定50%的高度设置是否将在整个浏览器中一致地工作 - 确保您测试它。如果没有,您可能需要使用像素度量。

Remember, the surrounding div needs to be position: relative for this to work. I'm not sure about whether the 50% height setting will work consistently throughout browsers - make sure you test it. You may have to resort to pixel measures if it doesn't.

这篇关于css border-left 50%height的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆