


i wrote a piece of css today. i suddenly thought of it while writing. i wrote it and shared it with you; we may have been used to it padding is different in different browsers, but you may not have noticed this;
let me talk about it first scenario, for example:
a 400px wide yellow box, a 300px small blue box on the left, and a 100px wide red box on the right. this should fit right in, right? because 300 100 is exactly 400! okay, let’s try it first. try!
i started writing (header omitted):
<style> #yellow{ width:400px; border:1px solid #ff9900; background:#ffcc99; float:left;} #blue{ width:300px; height:100px; border:1px solid #0066ff; background:#00ccff; float:left;} #red{ width:100px; height:100px; border:1px solid #ff3300; background:#ff9900; float:right;} </style> 400px <p id="yellow"> <p id="blue">300px</p> <p id="red">100px</p> </p>
look at the effect:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>www.zishu.cn</title> <style> *{ margin:0; padding:0;} body{padding:50px; font-size:12px; font-family:arial, helvetica, sans-serif; line-height:1.8;} #yellow{ width:400px; border:1px solid #ff9900; background:#ffcc99; float:left;} #blue{ width:300px; height:100px; border:1px solid #0066ff; background:#00ccff; float:left;} #red{ width:100px; height:100px; border:1px solid #ff3300; background:#ff9900; float:right;} </style> </head> <body> 400px <p id="yellow"> <p id="blue">300px</p> <p id="red">100px</p> </p> </body> </html>
the final effect is like this:
the reason why i didn’t put it down is because i wrote a border: 1px; then let’s remove it and take a look.
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>www.zishu.cn</title> <style> *{ margin:0; padding:0;} body{padding:50px; font-size:12px; font-family:arial, helvetica, sans-serif; line-height:1.8;} #yellow{ width:400px; border:1px solid #ff9900; background:#ffcc99; float:left;} #blue{ width:300px; height:100px; background:#00ccff; float:left;} #red{ width:100px; height:100px; background:#ff9900; float:right;} </style> </head> <body> 400px <p id="yellow"> <p id="blue">300px</p> <p id="red">100px</p> </p> </body> </html>
well, this is right, just put it down.
so:
the border is calculated outside the width. is that so? let’s look at the following code:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>www.zishu.cn</title> <style> *{ margin:0; padding:0;} body{padding:50px; font-size:12px; font-family:arial, helvetica, sans-serif; line-height:1.8;} #yellow{ width:400px; border:1px solid #ff9900; background:#ffcc99; float:left;} #blue{ width:300px; height:100px; border:1px solid #0066ff; background:#00ccff; float:left;} #red{ width:100px; height:100px; border:1px solid #ff3300; background:#ff9900; float:right;} </style> </head> <body> 400px <p id="yellow"> <p id="blue">300px</p> <p id="red">100px</p> </p> </body> </html>
if you are using ie; then you will see their interval much smaller, firefox should be the same as the original effect;
then look at the last effect:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>www.zishu.cn</title> <style> *{ margin:0; padding:0;} body{padding:50px; font-size:12px; font-family:arial, helvetica, sans-serif; line-height:1.8;} #yellow{ width:400px; background:#ffcc99; float:left;} #blue{ width:300px; height:100px; border:1px solid #0066ff; background:#00ccff; float:left;} #red{ width:100px; height:100px; border:1px solid #ff3300; background:#ff9900; float:right;} </style> </head> <body> 400px <p id="yellow"> <p id="blue">300px</p> <p id="red">100px</p> </p> </body> </html>
the two small boxes inside have borders, but there is no width. if it changes, i put it down in ie. firefox will not change.
look at the code difference, i added less:
program code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
if not add (not at all); it should be executed according to html3.0, i am not sure about this.
program code
transfer a section:
doctype is the abbreviation of document type (document type), used to describe your what version of xhtml or html is used?
the dtd (such as xhtml1-transitional.dtd in the above example) is called the document type definition, which contains the rules of the document. the browser will interpret the identity of your page based on the dtd you defined and display it.
this is a friendly reminder to keep this in mind when writing css. if the page comparison requirements are not quite strict, try to leave a little gap when calculating. in this way, even if there is a 1px border, it will not have a serious impact on the page. 1px is better, but if it is 10px, your page will be finished. i prefer: if the box has width, don't add padding. it's impossible not to add border. no one will laugh at multiple sets of one or two layers. these can avoid many browser compatibility issues.
the above is a summary of what you must pay attention to when writing css. for more related content, please pay attention to the php chinese website (www.php.cn)!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
