Home > Web Front-end > HTML Tutorial > The solution to defining the minimum height of span has no effect_HTML/Xhtml_Web page production

The solution to defining the minimum height of span has no effect_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:37:42
Original
1511 people have browsed it

The span tag is often used when making HTML web pages, but some friends have trouble using this tag. Many friends seem to think it is easy to use, but it is very troublesome to use, especially when it is necessary to define the width and height.

A friend once asked: Why after defining the height and width of a span with CSS, its width and height still do not change, as if it has failed?

In fact, this problem is very simple - you must first understand the attributes of span, because span is an inline element, and inline elements ignore width and height. Once you understand this, the solution is very simple. Solve The best way is to use css to turn span into a boxed element.

There are two ways to define an inline element as a boxed element:

1. Directly use the display attribute to define it as a boxed element;

Copy code
The code is as follows:

display:block;

2. Use floats The attribute float automatically defines it as a boxed element;

Copy the code
The code is as follows:

float:left;
Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template