Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Horizontal borders with padding

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

<!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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading