With the continuous development of Internet technology, web design has also received many changes and updates. The text box is one of the most commonly used elements in web design. Its setting not only affects the appearance of the website, but also affects the user experience and usability of the website. This article will introduce how to set up a CSS text box, including the basic style, background color, rounded border, shadow, transparency and animation effects of the text box.
1. Basic style of text box
The text box is one of the most widely used elements in web design. It allows users to enter a variety of information, such as search boxes and messages. box and comment box, etc. In CSS, we can use the following code to define the basic style of the text box:
input[type=text], textarea { width: 100%; padding: 12px 20px; margin: 8px 0; box-sizing: border-box; border: 2px solid #ccc; border-radius: 4px; background-color: #f8f8f8; font-size: 16px; resize: none; }
In the above CSS code, we use the input[type=text] selector and textarea selector to define the text box Basic style. Specific styles include the width, padding, margins, border, border color, border rounded corners, background color, font size and resizing of the text box.
2. The background color of the text box
The background color of the text box can be set through the CSS background-color property. You can customize the background color of the text box to meet different design needs. The following is an example, using dark gray as the background color of the text box:
input[type=text], textarea { background-color: #333; }
3. Rounded border of the text box
The rounded border is a commonly used text box design style. It can make the page look warmer and friendlier. In CSS, we can use the border-radius property to set the rounded size of the text box border. The following is an example:
input[type=text], textarea { border-radius: 10px; }
4. The shadow of the text box
The shadow can make the page elements look more three-dimensional and real. We can use the box-shadow property to set the shadow effect of the text box. The following is an example:
input[type=text], textarea { box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2); }
Among them, the first parameter represents the horizontal offset of the shadow, the second parameter represents the vertical offset, the third parameter represents the blur radius, and the fourth parameter represents the shadow color and transparency.
5. Transparency of the text box
Transparency refers to the opacity of the element. We can use the opacity attribute to use transparency in the text box. The following is an example:
input[type=text], textarea { opacity: 0.7; }
6. Animation effects of text boxes
Animation effects can make web page elements more eye-catching and improve user experience. We can use the CSS transition property to animate the text box. Here is an example:
input[type=text], textarea { transition: all 0.3s ease-in-out; } input[type=text]:hover, textarea:hover { transform: scale(1.05); }
The above code will add a magnification effect to the text box when the mouse is hovered. The first line of code sets the transition effect for all properties, and the second line of code adds a magnification effect.
Summary:
The text box is a commonly used element in web design. By using CSS to style the text box, you can make it more beautiful, improve user experience and website usability. The sample code provided here can be used as a reference for readers, and can also be personalized to meet different design needs.
The above is the detailed content of css text box settings. For more information, please follow other related articles on the PHP Chinese website!