Home > Web Front-end > CSS Tutorial > How to set minimum width in css

How to set minimum width in css

青灯夜游
Release: 2023-01-05 16:12:35
Original
4124 people have browsed it

In css, you can use the min-width attribute to set the minimum width. Just add the "min-width:length|%;" style to the element. The value "length" represents a numeric value with length units that defines a fixed-size minimum width; "%" defines a minimum width based on a percentage of the block-level object containing the element.

How to set minimum width in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The min-width attribute sets the minimum width of the element.

Note: The min-width attribute does not include padding, borders, or margins!

Attribute value:

Value Description
length Define the minimum width value of the element. Default: Depends on browser.
% Defines the minimum width based on the percentage of the block-level object that contains it.

Example:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style type="text/css">
    	.min{
    		min-width: 300px;
    	}
    </style>
  </head>
  <body>
  	<textarea>文本框默认宽度</textarea><br>
    <textarea class="min">文本框最小宽度300px</textarea>
  </body>
</html>
Copy after login

Rendering:

How to set minimum width in css

(Learn Video sharing: css video tutorial)

The above is the detailed content of How to set minimum width in css. For more information, please follow other related articles on the PHP Chinese website!

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