Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal borders with padding

Tags:

css

I'd like to have a simple div without any nested elements

<div class="border">čištění</div>

displaying horizontal dashed border inside the element (like within padding), like this

enter image description here

There is a outline-offset property, but it accepts only a single length value and vertical borders also appear. Is there any elegant solution?

In the suggested answer I can not see how to hide the vertical borders.

like image 294
Jan Turoň Avatar asked May 13 '26 17:05

Jan Turoň


1 Answers

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Document</title>
    <style>
      .border {
        display: flex;
        align-items: center;
        justify-content: center;
        outline: 5px solid green;
        outline-offset: -5px;
        border-top: 10px dashed #fff;
        border-bottom: 10px dashed #fff;
        background-color: green;
        color: white;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div class="border">čištění</div>
  </body>
</html>
like image 157
AG80 Avatar answered May 16 '26 07:05

AG80