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

How to build a SOLO personal blog from scratch using Docker

Table of contents 1. Environmental Preparation 2....

Implementation code of using select to select elements in Vue+Openlayer

Effect picture: Implementation code: <template...

Analysis of pitfalls in rounding operation of ROUND function in MySQL

This article uses examples to illustrate the pitf...

MySQL 8.0 New Features: Hash Join

The MySQL development team officially released th...

Simple example of HTML checkbox and radio style beautification

Simple example of HTML checkbox and radio style b...

Vue.set() and this.$set() usage and difference

When we use Vue for development, we may encounter...

Docker container custom hosts network access operation

Adding the extra_hosts keyword in docker-compose....

Let's talk in detail about the direction of slow SQL optimization in MySQL

Table of contents Preface SQL statement optimizat...

Detailed explanation of setting resource cache in nginx

I have always wanted to learn about caching. Afte...

One line of code solves various IE compatibility issues (IE6-IE10)

x-ua-compatible is used to specify the model for ...

Deploy the Vue project on a Linux server

Case 1 vue-cli builds the vue3 project, uploads t...

ES6 loop and iterable object examples

This article will examine the ES6 for ... of loop...