HTML Div border not showing

后端 未结 3 1197
一向
一向 2020-12-03 17:55

I\'m trying to add a border to a div element in HTML. Below is my code.

相关标签:
3条回答
  • 2020-12-03 18:05

    The default value of border-style is none. You need to set a different value for a border to appear.

    #container-border {
      border-width: 2px;
      border-color: red;
      border-style: dashed;
    }
    <div id="container-border">
      ...
    </div>

    0 讨论(0)
  • 2020-12-03 18:17

    You have to set the rule "border-style" to see the border

    #container-border {
      border-width: 2px;
      border-color: red;
      border-style:solid;
    }
    <div id="container-border">
      ...
    </div>

    0 讨论(0)
  • 2020-12-03 18:27

    You can use the shortcode for border, which contains color, width AND style (which you are missing right now):

    #container-border {
      border: 2px solid red;
    }
    
    0 讨论(0)
提交回复
热议问题