• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • border-top

    CSS属性border-top是属性border-top-color,border-top-style,和border-top-width的三者的缩写。这些属性都是在描述一个元素的上方的边框border

    border-top: solid;
    border-top: dashed red;
    border-top: 1rem solid;
    border-top: thick double #32a1ce;
    border-top: 4mm ridge rgb(170, 50, 220, .6);
    

    与所有缩写属性(shorthand properties)一样,border-top始终设置它可以设置的所有属性的值,即使未指定它们也是如此。它将未指定的那些设置为其默认值。这意味着

    border-top-style: dotted;
    border-top: thick green;
    

    和下面的代码效果相同:

    border-top-style: dotted;
    border-top: none thick green;
    

    在border-top前指定的border-top-style将会失效。因为border-top-style默认值为none,故没有边界即没有指定border-style

    示例

    border-top: 1px;
    border-top: 2px dotted;
    border-top: medium dashed green;
    

    浏览器支持

    IE浏览器火狐浏览器opera浏览器chrome浏览器safari浏览器
    浏览器都支持border-top

    语法

    border-top:border-width| border-top-style| border-top-color

    取值:

    • border-width:设置或检索对象边框宽度。取值<length>| thin| medium| thick。参见border-width
    • border-top-style:设置或检索对象边框样式。取值 none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset。参见border-top-style
    • border-top-color:设置或检索对象边框颜色。。参见border-top-color
    初始值
    适用于所有元素,::first-letter
    继承性
    动画性
    计算值

    实例

    <div>
      this box has a border on the top side.
    </div>
    
    div {
      border-top: 4px dashed blue;
      background-color: gold;
      height: 100px;
      width: 100px;
      font-weight: bold;
      text-align: center;
    }
    

    上篇:border-color

    下篇:border-top-width