In CSS, you can use the border-top attribute to set the top border. You only need to set the "boder-top:width style color" style to the element; this attribute can be set in order: border-top-width, border-top-style and border-top-color.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
1. Border style
a. Border-width attribute
Custom border Width cannot be defined as a percentage.
b. border-style attribute
The above attributes can be set with one, two, three, or four attribute values. When setting a value, four This attribute value is applied to all borders. When two are set, the first attribute value is used for up and down, and the second attribute value is used for left and right. When three values are set, the first value is applied to the top border, and the second one is used for the left and right sides. Apply to the left and right borders, and the third attribute value is applied to the bottom border. When four attribute values are set, apply them one at a time in a clockwise direction. In most cases, groove, ridge, inset, and outset can use two-color borders, but when the border-color attribute is set to black, both colors will be displayed as black.
2. Apply a border style to a side
boder-top/bottom/right/left-width/style/color is used to set the style of a border, and can be combined with general properties In conjunction with. You can also use border-bottom/top/left/right to set one border at a time.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> div{ width: 100px; height:200px; border-width: 10px; border-style: ridge; border-color: red; border-top-style: double; } </style> </head> <body> <div> </div> </body> </html>
3. Use the border abbreviation attribute
You can use it once to set the width, style, and color of the border. Separate the three attribute values with spaces. . The order among the three attributes can be disrupted.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> div{ width: 100px; height:200px; border:solid 2px red ; } </style> </head> <body> <div> </div> </body> </html>
4. Create a rounded border
border-top/bottom-left/right-radius
Set a rounded corner, A pair of length values or percentages relative to the width and height of the border box. The first value is the horizontal radius of the ellipse's border, and the second value is the vertical radius of the ellipse. If only one value is the radius of a circle, separate the two values with a space.
Border -radius
Set the four rounded corners of the border at one time, one pair, two pairs, three pairs, four pairs of length values or percentages, and the horizontal radius and vertical radius are separated by / .
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> div{ width: 100px; height:200px; border:solid 2px red; border-top-left-radius: 20px 10px } </style> </head> <body> <div> </div> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> div{ width: 100px; height:200px; border:solid 2px red; border-radius: 20px/10px } </style> </head> <body> <div> </div> </body> </html>
When there is a pair or one attribute value, the four rounded corners are the same, and when there are two attribute values, the first one The attribute value corresponds to the upper left and lower right, the second corresponds to the upper right and lower left, and the three attribute values correspond to the upper left, (upper right, lower left), and lower right. The four attribute values are in clockwise direction.
5. Image border
The browser compatibility of the image border is not good. In many cases, it is necessary to add the browser manufacturer prefix in front of the attribute. In order to provide better compatibility, it is recommended to use it as follows.
a. border-image-source
You must use the url function to specify the image source.
b. border-image-slice attribute
This attribute specifies the inward offset of the upper, right, lower, and left edges of the image. It is divided into nine areas: four corners, four sides and a middle area. Unless the fill keyword is used, the middle portion of the image is discarded. If the fourth value/percentage is omitted, it is the same as the second value. If the third value is omitted, it is the same as the first value. If the second value is omitted, it is the same as the first value.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> div{ width: 500px; height: 400px; background: red; /*border-image-source:url(1.png); border-image-slice:89; border-image-width: 89px; border-image-repeat: stretch; border-image-outset: 10px;*/ border-image:url(1.png) 89 30 89 30 fill/89px repeat } </style> </head> <body> <div> </div> </body> </html>
Cutting picture:
c、border-image-outset
When this attribute is not set, the border will occupy the content area. When you need to set it, you can add "/" after the width of the border to set the attribute value.
d、border-repeat
e、border-image
You can set the above properties at once. border-image:souce slice/width/outset repeat
Recommended learning: css video tutorial
The above is the detailed content of How to set the top border in css. For more information, please follow other related articles on the PHP Chinese website!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
