Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a inner border for a box in html?

How to Create a inner border for a box in html?

See this picture:

What I want

like image 207
DigiMan Avatar asked Jan 11 '17 12:01

DigiMan


People also ask

How do I make an inner border?

To set the inner border, you can use the “box-sizing”, “outline”, and “box-shadow” CSS properties. The box-sizing property is used to restrict the expansion of the added border. The outline property is used in combination with the outline-offset for adding an outline as an inner border.

How do you put a border inside a div in CSS?

To place a border inside the div, first, create a border using the “border” property, then use the “box-shadow” and “outline” with “outline-offset” and “box-sizing” properties of CSS. The border property creates a border around the element, and the other four properties can be used to move the border inside the div.


1 Answers

Take a look at this , we can simply do this with outline-offset property

Output image look like

enter image description here

.black_box {
    width:500px;
    height:200px;
    background:#000;
    float:left;
    border:2px solid #000;
    outline: 1px dashed #fff;
    outline-offset: -10px;
}
<div class="black_box"></div>
like image 147
Jishnu V S Avatar answered Sep 23 '22 12:09

Jishnu V S