简体   繁体   中英

javascript - get div width and add to border

Hey I want to get the width of a div and add it to a css class as border width . Thanks in advance!

Here is the div:

<div id="web" class="well">
<div style="padding:19px">
<a style="text-decoration:none;" class="boxclose web_close"></a>
<h2 style="color:#242424; font-weight:bold;"><em style="color:#4fd886;">&mdash;</em>  Web.</h2>
<p></p>
</div>
</div>

and here is the CSS class:

.well:before { 
    width: 0;
    height: 0;
    content: "";
    border-bottom: 81px solid #fff;
    border-left:/*WIDTH HERE*/ solid transparent;
    position: absolute;
    bottom: 100%;
}

I didn't mention you want border any one sided like border-left, right etc. or border in all direction. I've tried to solve your query please find fiddle link below..

find js fiddle demo

.well{
position:relative;
float:left;
}
.well:before { 
width: 100%;
height: 100%;
content: "";
position: absolute;
top: 0;
left:0;
border:1px solid red;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM