How to add padding to the beginning and end of each line of text within a span element with a background color?

Linda Hamilton
Release: 2024-11-07 08:56:02
Original
211 people have browsed it

How to add padding to the beginning and end of each line of text within a span element with a background color?

Padding Text Lines

Question:

How do you add padding to the beginning and end of each line of text within a span element that has a background color?

Answer:

CSS Solution:

This solution requires using inline blocks and careful positioning:

div { 
    line-height: 1.1; 
    padding: 1px 0;
    border-left: 30px solid #000; 
    display: inline-block; 
}
h3 { 
    background-color: #000; 
    color: #fff; 
    display: inline; 
    margin: 0; 
    padding: 0
} 
h3 .indent { 
    position: relative; 
    left: -15px;
}
h3 .subhead {
    padding: 0 15px;
    float: left;
    margin: 3px 0 0 -29px;
    outline: 1px solid #00a3d0;
    line-height: 1.15
}
Copy after login

HTML Markup:

<div>
Copy after login

The above is the detailed content of How to add padding to the beginning and end of each line of text within a span element with a background color?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!