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

How to set minimum width in css

青灯夜游
青灯夜游Original
2021-04-28 17:21:274133browse

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>

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!

Statement:
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
Previous article:css what languageNext article:css what language