简体   繁体   English

如何使用css在div上具有多个边框

[英]How to have multiple borders on div using css

I have searched alot, but i did not find any solution. 我已经搜索了很多,但没有找到任何解决方案。 I want to have border at bottom something like below image. 我想在底部有边框,如下图所示。 multiple border how can i have this type of border on div. 多重边框如何在div上使用这种类型的边框。 I also want to have cricle image with shadow circle like this circle image 我也想像这样的圆形图像有阴影圆圈的cicle 图像

To add border at bottom in the first image i have added this code: 为了在第一张图片的底部添加边框,我添加了以下代码:

.login-wrapper {
    background-color: #fff;
    padding: 20px 30px;
    margin: 0 auto;
    border-bottom: 1px solid #333333;
    box-shadow: 0 2px 0 0 #338833, 0 2px 0 0 #883333;
}

but, It is not generating the desired output. 但是,它没有生成所需的输出。

To get the desire output for second image. 获取第二张图片的期望输出。 I have added the below code. 我添加了以下代码。

for circle image i have added this code: 对于圆圈图像,我添加了以下代码:

<div class="login-wrapper" ng-controller="loginController">
    <div class="field-wrapper">
        <div class="login-img-wrapper">
            <img src="img/person.png" class="img-circle" />
            <div class="shadow"></div>
        </div>
    </div>
</div>

.login-img-wrapper img {
    border: 1px solid #f4f4f4;
    background-color: #f4f4f4;
    padding: 5px;
    height: 70px;
    width: 70px;
    border-radious: 50%;
}

.login-img-wrapper .shadow {
    background-image: linear-gradient(130deg, white 50%, transparent 40%);
    opacity: .7;
    z-index: 15;
    position: absolute;
    height: 60px;
    width: 60px;
    top: 0;
}

but this is not generating the same image. 但这不会生成相同的图像。 Please somebody help me. 请有人帮我。

What output i have got after aplying above defined css for second image 我在第二张图片上使用高于定义的css后得到的输出 应用以上定义的CSS后的临界图像 .

You can try with box-shadow : 您可以尝试使用box-shadow

 .border-box { background:#ff0; display:inline-block; width:200px; height:20px; box-shadow: 0 1px 0 #999, 0 2px 0 #fff, 0 3px 0 #999, 0 4px 0 #fff, 0 8px 0 #999; } 
 <div class="border-box"></div> 

For your second image: 对于第二张图片:

 .circle-image { width:200px; height:200px; display:inline-block; background:#ccc; border-radius:50%; position:relative; text-align:center; } .circle-inner { width:200px; height:200px; display:inline-block; border-radius:50%; position:relative; transform:rotate(-45deg); position:absolute; top:0; left:0; } .circle-inner:after { content:""; width:200px; height:90px; display:inline-block; background:rgba(255,255,255,.3); border-radius:200px 200px 0 0; position:absolute; top:0; left:0; } 
 <div class="circle-image"> <div class="circle-inner"></div> </div> 

You typed the radius spelling wrong. 您输入的radius拼写错误。

.login-img-wrapper img {
    border: 1px solid #f4f4f4;
    background-color: #f4f4f4;
    padding: 5px;
    height: 70px;
    width: 70px;
    border-radius: 50%;
}

Here is a start from where you can experiment with circle, shadow and border. 这是您可以尝试使用圆形,阴影和边框的起点。

Fiddle Demo 1 小提琴演示1
Fiddle Demo 2 (Changed border/padding for image) 小提琴演示2 (更改图像的边框/填充)

<div class="login-wrapper" ng-controller="loginController">
    <div class="field-wrapper">
        <div class="login-img-wrapper">
            <img src="http://lorempixel.com/output/people-q-c-100-100-9.jpg" />
            <div class="shadow"></div>
        </div>
    </div>
</div>


.login-img-wrapper {
    position: relative;
    height: 150px;
    width: 150px;
    background-color: #eee;
    margin: auto;
    border-bottom: 1px solid #bbb;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.login-img-wrapper:after,
.login-img-wrapper:before {
    z-index: -1;
    height: 4px;    
    bottom: -5px;
    left: 6px;
    right: 6px;
    background-color: #eee;
    border-bottom: 1px solid #bbb;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    content:" ";
    position: absolute;
}
.login-img-wrapper:after {
    bottom: -3px;
    left: 3px;
    right: 3px;
}
.login-img-wrapper:before {
    box-shadow: 0 0 10px gray;
}

.login-img-wrapper img {
    border: 1px solid #f4f4f4;
    background-color: #f4f4f4;
    padding: 5px;
    height: 90px;
    width: 90px;
    border-radius: 50%;
    box-shadow: 0 0 10px gray;
}

.login-img-wrapper .shadow {
    background: linear-gradient(130deg, white 50%, transparent 40%);
    border-radius: 50%;
    opacity: .7;
    z-index: 15;
    position: absolute;
    height: 100px;
    width: 100px;
    top: 0;
}

Update 更新

Using the new CSS clip-path shapes circles, ellipses, and polygons, more advanced masking and shapes can be done, though it still has bad browser support. 使用新的CSS clip-path形状的圆形,椭圆形和多边形,可以完成更高级的蒙版和形状,尽管它仍然对浏览器支持不佳。

Read more about it here: https://css-tricks.com/clipping-masking-css/ 在此处了解更多信息: https : //css-tricks.com/clipping-masking-css/

For even more advanced clipping/shadowing (and better browser support) I recommend to start using SVG in combination with CSS. 为了获得更高级的剪辑/阴影效果(以及更好的浏览器支持),我建议开始将SVG与CSS结合使用。

As a start here is some ways to go: Draw a crescent moon using SVG in HTML 首先,这里有一些方法: 在HTML中使用SVG绘制新月

如何折叠一组的边框<div>使用 CSS 的标签?</div><div id="text_translate"><p> 我有一个由 DIV 组成的网格,宽度固定,边框为 1 像素。 现在,当两个 DIV 相互接触时,边框显然变为 2px。</p><p> 我怎样才能在整个网格中得到一个 1px 的边框?</p><p> 这就是我的意思:</p><p><img src="https://i.stack.imgur.com/QdQ0L.png" alt=""></p><p> <a href="http://jsfiddle.net/Before/4uPtj/" rel="nofollow noreferrer">http://jsfiddle.net/Before/4uPtj/</a></p><p> HTML:</p><pre> <div class="gridcontainer"> <div class="griditem"></div> <!-- 15 more times --> </div></pre><p> CSS:</p><pre> div.gridcontainer { width: 80px; line-height: 0; } div.griditem { display: inline-block; border: 1px solid black; width: 18px; height: 18px; }</pre></div> - How to collapse the borders of a set of <div> tags using CSS?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 css 中设置 div 的边框 - How to style borders of a div in css 如何折叠一组的边框<div>使用 CSS 的标签?</div><div id="text_translate"><p> 我有一个由 DIV 组成的网格,宽度固定,边框为 1 像素。 现在,当两个 DIV 相互接触时,边框显然变为 2px。</p><p> 我怎样才能在整个网格中得到一个 1px 的边框?</p><p> 这就是我的意思:</p><p><img src="https://i.stack.imgur.com/QdQ0L.png" alt=""></p><p> <a href="http://jsfiddle.net/Before/4uPtj/" rel="nofollow noreferrer">http://jsfiddle.net/Before/4uPtj/</a></p><p> HTML:</p><pre> <div class="gridcontainer"> <div class="griditem"></div> <!-- 15 more times --> </div></pre><p> CSS:</p><pre> div.gridcontainer { width: 80px; line-height: 0; } div.griditem { display: inline-block; border: 1px solid black; width: 18px; height: 18px; }</pre></div> - How to collapse the borders of a set of <div> tags using CSS? 如何使用带有边框的CSS制作形状? - How to make shapes with CSS which have borders? 如何使用CSS 3保持弯曲的边框 - How to keep curved borders using css 3 如何在使用CSS滤镜时保留边框 - How to preserve borders while using css filters CSS div麻烦(边界和图像) - CSS div troubles (borders and images) CSS:合并Div和表格边框 - CSS: Merging Div and Table Borders 如何使用 css 淡出/模糊 div 的边框? - how to fade-out/blur div's borders with css? 如何使CSS元素超出包含div的所有边界? - How to make a CSS element extend beyond all borders of containing div? 如何在带有圆形边框的css3 div中将字符居中 - how to center a character in a css3 div with rounded borders
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM