Summary of tips for making web pages

Summary of tips for making web pages

Preface

This article mainly summarizes some of the problem-solving skills encountered in daily web page production, and shares them for your reference and learning. I won’t say much below. Interested friends can take a look at the detailed introduction below:

To summarize:

1. Box-sizing: allows you to define specific elements that match a certain area in a specific way.

content-box: Add padding and borders to a box in addition to the specified width and height.

border-box: (Default value for textarea and select) Add padding and borders to the box within the specified width and height.

/*It depends on your personal preference, but the default attribute of general tags is content-box, except for textarea and select*/
   box-sizing: content-box;
   -moz-box-sizing: content-box; 
   -webkit-box-sizing: content-box;

2. Beautify the input box

/*In IE10+ browsers, use CSS to hide the cross on the right side of the input text input box*/
input[type=text]::-ms-clear,::-ms-reveal{display:none;}
input::-ms-clear,::-ms-reveal{display:none;}
input{
  /*Remove the outline color when clicking*/
  outline: none;
  /*The padding has been removed in the reset style. If it is not removed, remember to have padding*/    
}

3. Beautify the textarea text field

textarea{
    /*Don't forget that the box-sizing property value of the text area is border-box; all borders and padding are drawn based on your fixed width and height*/
     /*Remove the outline color when clicking*/
      outline: none;    
      /*If necessary, remove the resizable icons and functions in the lower right corner*/
      resize: none;
      /*The padding has been removed in the reset style. If it is not removed, remember to have padding*/
}

4. Change the font color and size of the placeholder

input::-webkit-input-placeholder { 
    /* WebKit browsers */ 
    font-size:14px;
    color: #333;
} 
input:-moz-placeholder { 
    /* Mozilla Firefox 4 to 18 */ 
    font-size:14px;
    color: #333;
} 
input::-moz-placeholder { 
    /* Mozilla Firefox 19+ */ 
    font-size:14px;
    color: #333;
} 
input:-ms-input-placeholder { 
    /* Internet Explorer 10+ */ 
    font-size:14px;
    color: #333;
}

5. Beautify selection

/* Clear IE's default selection box style and hide the drop-down arrow */
select::-ms-expand { display: none; }
select {
  /*The borders in Chrome and Firefox are different, so I copied them*/
  border: solid 1px #333;

  /*Clear the default select box style*/
  appearance:none;
  -moz-appearance:none;
  -webkit-appearance:none;

  /*Display a small arrow image in the middle of the rightmost selection box*/
  background: url("small arrow image path") no-repeat right center transparent;

  /*Leave some space for the drop-down arrow to avoid being covered by text*/
  padding-right: 14px;

  /*Remove the outline color when clicking*/
  outline: none;
}

6. Beautify button

button{
    /*It has a 2px border, and ordinary buttons do not need a border*/
    border: none;
    /*The original background color can be replaced by other colors*/
    background: #333;
    /*The padding has been removed in the reset style. If it is not removed, remember to have padding*/
}

7. Beautify radio buttons, multiple-selection boxes, or upload file buttons

/*Because you can't directly change the style of input[type="radio"] and input[type="cheakbox"], you need to use label tag association, then hide the input tag and directly give the label tag style. Selecting label means selecting this label*/
<label for="sex">Male</label>
<input type="radio" id="sex" value="Male" />

8. Use ellipsis to indicate extra text

white-space: nowrap; /* Force no line break */
overflow:hidden; /*Hide the excess content when the content exceeds the width*/ 
text-overflow:ellipsis;/* Displays an ellipsis mark (...) when the text in the object overflows. It must be used together with overflow:hidden;. */

9. How to remove the blue background when clicking text on a CSS page

-moz-user-select: none; /* Firefox*/
-webkit-user-select: none; /* webkit browser */
-ms-user-select: none; /* IE10 */
-khtml-user-select: none; /* Early browsers */
user-select: none;

10. Use this property when the vertical position of the icon is difficult to adjust

vertical-align: 30%;
vertical-align: middle;

11. How to center a div in the page

div{
    width:400px;
    height:300px;
    position:absolute;
    top:50%;
    left:50%;
    margin:-150px 0 0 -200px;
}

12.js

// Return key written in js onclick = 'history.go(-1)';

// Force refresh page window.location.reload(true);

13. Line break, no line break, word spacing

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM

<<:  How to create a table in mysql and add field comments

>>:  Docker enables seamless calling of shell commands between container and host

Recommend

A detailed introduction to the netstat command in Linux

Table of contents 1. Introduction 2. Output Infor...

JavaScript setTimeout and setTimeinterval use cases explained

Both methods can be used to execute a piece of ja...

Detailed tutorial on installing MYSQL under WINDOWS

1. Download the installation package -Choose the ...

SVG button example code based on CSS animation

The specific code is as follows: <a href="...

Introduction to MySQL Connection Control Plugin

Table of contents 1. Introduction to the connecti...

Solution to the Docker container cannot be stopped and deleted

Find the running container id docker ps Find the ...

4 ways to implement routing transition effects in Vue

Vue router transitions are a quick and easy way t...

The process of building lamp architecture through docker container

Table of contents 1. Pull the centos image 2. Bui...

Essential knowledge for web development interviews and written tests (must read)

The difference between inline elements and block-...

Use of kubernetes YAML files

Table of contents 01 Introduction to YAML files Y...

Several common methods of CSS equal height layout

Equal height layout Refers to the layout of child...

20 excellent foreign web page color matching cases sharing

This article collects 20 excellent web page color ...

Examples of using the Li tag in HTML

I hope to align the title on the left and the dat...

How to configure SSL for koa2 service

I. Introduction 1: SSL Certificate My domain name...

Vue implements infinite loading waterfall flow

This article example shares the specific code of ...