为什么我极其基本的CSS代码在jsFiddle和jsBin上产生不同的输出? [英] Why does my extremely basic CSS code produce different outputs on jsFiddle and jsBin?

查看:148
本文介绍了为什么我极其基本的CSS代码在jsFiddle和jsBin上产生不同的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个不同的输出,但是完全一样的超基本代码:

CSS

  input {
display:block;
min-width:200px;
padding:10px;
}

HTML $ b

 < input type =text/> 
< input type =text/>
< input type =submitvalue =Register/>

jsFiddle 上产生以下输出(现场演示)



我已经在最新的Firefox中测试过这个Chrome(无处不在)。
在一个普通的裸体.html文件中,它看起来像在jsBin btw ...

解决方案

区别在于



从JS Bin(无文档类型):

 < ; HTML> 

来自jsFiddle(html5 doctype):

 <!DOCTYPE html> 

在JS Bin上缺少doctype会将浏览器拖入怪癖模式。显然怪癖模式和标准模式对盒子尺寸属性使用不同的默认值。


Two different outputs, but exactly the same super-basic code:

CSS

input {
  display: block;
  min-width: 200px;
  padding: 10px;
}

HTML

<input type="text" />
<input type="text" />
<input type="submit" value="Register" />

produces the following output on jsFiddle (live demo here),

but this output in jsBin (live demo here)

I have tested this in latest Firefox and Chrome (same differences everywhere). In a plain naked .html file, it looks like on jsBin btw...

解决方案

The difference is the doctype.

From JS Bin (no doctype):

<html>

From jsFiddle (html5 doctype):

<!DOCTYPE html>

The lack of a doctype on JS Bin is throwing the browser into quirks mode. Apparently quirks mode and standards mode use a different default value for the box-sizing property.

这篇关于为什么我极其基本的CSS代码在jsFiddle和jsBin上产生不同的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆