Home Web Front-end HTML Tutorial css tips memo_html/css_WEB-ITnose

css tips memo_html/css_WEB-ITnose

Jun 24, 2016 am 11:51 AM

Preface: In the process of learning and practicing CSS, I often forget some seemingly commonly used codes. In order to strengthen my memory, I will summarize them here and add and delete them one after another for immediate reference. I hope that I can solve problems in time in the future and keep these strange characters in mind.

1. About forced alignment of paragraph text

text-align:justify; text-justify:inter-ideograph ;

If you want to align the text at both ends, you must first define the width of P, then { text-align:justify; text-justify :distribute-all-lines; }

2. Add CSS to the different states of the button

Html code

  1.                                         ;input type="button"
  2. onMouseOver="this.className='over';"
  3. onMouseOut="this.className=' ';"
  4. onMouseDown= "this.className='down';"
  5. onMouseUp="this.className='over';"
  6. value="Unclicked button"
  7. onClick ="this.value='The clicked button'" name="Button">
  8. Three,
  9. in Import another CSS from one CSS file

@import url(***.css);

Four , Gradient background color (you must add width or height to use this)

FILTER:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#EEF5F8,endColorStr=#ffffff);

When using this, you must pay attention to defining the width or height value of the DIV.

Css code

.gradient { 

 /* Firefox 3.6 */ 

background-image: -moz-linear-gradient(top, #81a8cb, #4477a1);

  1. /* Safari & Chrome */ image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #4477a1),color-stop(1, #81a8cb));
  2. /* IE6 & IE7 */ 
  3. filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#81a8cb', endColorstr='#4477a1'); 
  4.  
  5. /* IE8 */ 
  6. -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#81a8cb', endColorstr='#4477a1')"; 
  7. background:#f4faff9;
  8. background:linear-gradient(#fff 0%,#f1f9ff 100 %) no-repeat;
  9. background:-moz-linear-gradient(#fff 0%,#f1f9ff 100%) no-repeat;
  10. background:-webkit-gradient(linear,0 0,0 100% ,from(#fff),to(#f1f9ff)) no-repeat;
background:-o-linear-gradient(#fff 0%,#f1f9ff 100%) no-repeat


5. Use PNG images to create transparent effects in IE6


*html #id{ filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled =true, sizingMethod=scale, src=images/*.png); background:none; }

6. Single line omitted text

{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

When using this, you must pay attention to defining the width of a single line (such as div or li) that needs to omit text value.

7. Code for setting as homepage and adding to favorites

Html code

  1. Set as homepage|Contact us |Add to favorites

8. Chinese stroke effect

Java code

  1. class="sizscolor"> Chinese stroke effect
  • 9. Adjust word spacing
  • { text-transform: uppercase; letter-spacing: 2px }
  • 10. The problem of doubling margin

    The margin set for a div set to float under IE will be doubled. This is a bug that exists in ie6. The solution is to add display:inline; to this div. For example: <#div id="imfloat"> The corresponding css is #IamFloat{ float:left; margin:5px; /*under IE, it is understood as 10px*/ display:inline;/*Under IE, it will be understood as 5px*/}

    11. Putting the mouse on the picture will make the picture brighter

    You can use pictures to replace the technique, or you can use the following filters. The code is as follows:

    .pictures img { filter: alpha(opacity=45); }

    .pictures a:hover img { filter: alpha(opacity=90); }

    12. Distinguish between different browsers

    Difference between FF, IE7 and IE6:

    background: orange ;* background:green !important ;*background:blue ;

    Note: IE can recognize *; standard browsers (such as FF) cannot recognize *;

    IE6 can recognize *, but not !important, IE7 can recognize *, but also !important;

    FF cannot recognize *, but can recognize !important;

    One more thing to add, underscore "_ ",
    IE6 supports underline, but neither IE7 nor firefox supports underline.

    So you can also distinguish IE6, IE7, firefox in this way
    : background:orange ;* background:green ;_ background:blue ;

    Note: No matter what method is used, the order of writing is that firefox is written at the front, IE7 is written in the middle, and IE6 is written at the end.

    13. Single-line image text vertically aligned in the center

    style *{vertical-align:middle;...}

    14. Input plus style (1)

    input[type~=radio]
    {
    ...
    }

    Meaning: Please apply the following style to all inputs, except for inputs whose type attribute is radio.

    15. Add style to input (2)

    16. Add shadow to text

    h1 { float: left; text-indent:0em; text-shadow:black 2px 2px 2px; filter: dropshadow(OffX=2, OffY=2, Color='black', Positive='true');

    17. Use Javascript and CSS to remove the dotted box and underline in the link

    Add onFocus= in the link tag "if(this.blur)this.blur()" can block the dotted box that appears around the click, such as:

    18. input type="image "

    19. Delete the dotted box on the link

    a:active, a:focus { outline:none; }  
    Copy after login

    20. Change the style of the upload button

    Html code

    or

    Html code

    1. < ;input type="file" id="file" size="1" style="width:100" class="upload">
    2. Upload< /a>

    Css code

    1. #uploadImg{ font-size:12px; overflow:hidden; position:absolute;  left:190px; top:6px; }  
    2. #uploadImg a { color:#000; line-height:24px; text-align:center; display:block; width:70px; margin:0; height:24px; border:1px solid #aecbd3; background:url(../images/btnbj.gif) repeat-x 0 0; }  
    3. #file{ position:absolute; z-index:100; margin-left:-180px; font-size:60px;opacity:0;filter:alpha(opacity=0); margin-top:-5px;}  

     

    Html代码  

    1.   
    2.   
    3.   
    4.   

    5.   
    6.   
    7.   

    8.   
    9.   
    10.   

    11.   
    12.   
    13.   
      

     

     

    二十一、css bug

     

      IE6 IE7 IE8 Firefox Chrome Safari
    !important   Y   Y    
    _ Y          
    * Y Y        
    *   Y        
    9 Y Y Y      
    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

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Hot Topics

    Java Tutorial
    1663
    14
    PHP Tutorial
    1266
    29
    C# Tutorial
    1239
    24
    Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

    WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

    The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

    HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

    HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

    HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

    HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

    The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

    The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

    The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

    The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

    The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

    HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

    The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

    HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

    HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

    See all articles