Hướng dẫn how do i put a horizontal line between words in html? - làm cách nào để đặt một đường ngang giữa các từ trong html?

Tôi đã tìm kiếm một số giải pháp cho trang trí đơn giản này và tôi đã tìm thấy khá nhiều loại, một số điều kỳ lạ, một số thậm chí với JS để tính toán chiều cao của phông chữ và bla, bla, bla, sau đó tôi đã đọc Một trong bài đăng này và đọc một bình luận từ baydot nói về fieldsetlegend và tôi nghĩ đó là nó.thirtydot speaking about fieldset and legend and I thought that was it.

Tôi đang ghi đè lên 2 kiểu yếu tố đó, tôi đoán bạn có thể sao chép các tiêu chuẩn W3C cho chúng và đưa nó vào lớp .middle-line-text của bạn [hoặc bất cứ điều gì bạn muốn gọi nó] nhưng đây là những gì tôi đã làm:


    Your text goes here



.featured-header{
    border-bottom: none;
    border-left: none;
    border-right: none;
    text-align: center;
 }

.featured-header legend{
    -webkit-padding-start: 8px; /* It sets the whitespace between the line and the text */
    -webkit-padding-end: 8px; 
    background: transparent; /** It's cool because you don't need to fill your bg-color as you would need to in some of the other examples that you can find [: */
    font-weight: normal; /* I preffer the text to be regular instead of bold  */
    color: YOU_CHOOSE;
}   


Đây là fiddle: //jsfiddle.net/legnaleama/3t7wjpa2/

Tôi đã chơi với các kiểu biên giới và nó cũng hoạt động trong Android;] [được thử nghiệm trên KitKat 4.xx]

EDIT:

Theo ý tưởng của Bekerov Artur cũng là một tùy chọn hay, tôi đã thay đổi hình ảnh .png Base64 để tạo đột quỵ bằng .SVG để bạn có thể hiển thị trong bất kỳ độ phân giải nào và cũng thay đổi màu của phần tử mà không cần bất kỳ phần mềm nào khác liên quan :]

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9
/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
1>

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9
                     
3>

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9html>

Output:

Ví dụ 2: Ví dụ này mô tả thẻ với các thuộc tính khác nhau và các giá trị của chúng để tạo kiểu đường ngang.This example describes the tag with various attribute & their values to style the horizontal line.

HTML

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9
/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
1>

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9html>

Output:

Thêm đường ngang bằng các thuộc tính CSS: trong trường hợp này, chúng tôi sẽ sử dụng thuộc tính kiểu đường viền để tạo đường ngang. Chúng ta có thể sử dụng thuộc tính Border-Top để chỉ định kiểu của đường viền trên cùng hoặc thuộc tính Border-Bottom, có thể đặt kiểu của đường viền dưới cùng của một phần tử. Cả hai thuộc tính có thể được sử dụng để thêm đường ngang.In this case, we will be using the border-style Propertyto create the horizontal line. We can either use the border-top property that specifies the style of the top border or the border-bottom property, which can set the style of the bottom border of an element. Both properties can be used to add the horizontal line.

Ví dụ 3: Ví dụ này mô tả bản vẽ của đường ngang bằng cách sử dụng thuộc tính kiểu đường viền.This example describes the drawing of the horizontal line using the border-style Property.

HTML

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9
/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
1>

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
3

/* SVG solution based on Bekerov Artur */
/* Flexible solution, scalable, adaptable and also color customizable*/
.stroke {
background-image: url["data:image/svg+xml;utf8,"];
background-repeat: repeat-x;
background-position: left;
text-align: center;
}
.stroke h3 {
background-color: #ffffff;
margin: 0 auto;
padding:0 10px;
display: inline-block;
font-size: 66px;
}
9html>

Output:


Làm cách nào để thêm một đường ngang giữa văn bản trong HTML?

Thẻ là một thẻ trống.Nó có nghĩa là nó không yêu cầu một thẻ cuối.Vì vậy, bạn cần gõ để thêm một dòng ngang vào trang HTML.type to add a horizontal line to an HTML page.

Làm thế nào để bạn tạo một đường phân cách ngang trong HTML?

Thẻ HTML Thẻ trong HTML là viết tắt của quy tắc ngang và được sử dụng để chèn quy tắc ngang hoặc ngắt chủ đề trong trang HTML để chia hoặc các phần tài liệu riêng biệt.Thẻ là một thẻ trống và nó không yêu cầu thẻ cuối.Được sử dụng để chỉ định sự liên kết của quy tắc ngang. The tag in HTML stands for horizontal rule and is used to insert a horizontal rule or a thematic break in an HTML page to divide or separate document sections. The tag is an empty tag, and it does not require an end tag. Used to specify the alignment of the horizontal rule.

Bài Viết Liên Quan

Chủ Đề