GVKun编程网logo

浏览器的HTML元素默认CSS(html默认浏览器怎么设置)

2

对于浏览器的HTML元素默认CSS感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍html默认浏览器怎么设置,并为您提供关于2013全面兼容多浏览器IE6?8&火狐&其他主流浏览器的CSSHAC

对于浏览器的HTML元素默认CSS感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍html默认浏览器怎么设置,并为您提供关于2013全面兼容多浏览器IE6?8&火狐&其他主流浏览器的CSS HACK写法_html/css_WEB-ITnose、android – 如何调整instagram应用内浏览器的html / css布局?、css html元素居中与html元素内容居中的区别、css – 为什么我的HTML元素之间会出现空格?的有用信息。

本文目录一览:

浏览器的HTML元素默认CSS(html默认浏览器怎么设置)

浏览器的HTML元素默认CSS(html默认浏览器怎么设置)

如何解决浏览器的HTML元素默认CSS?

找到所有W3CHTML规范和供应商默认CSS样式表的GitHub存储库。

1.

2.

3.

4.

5.

6.

根据默认W3C HTML4规范的示例:

html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre   { display: block; unicode-bidi: embed }
li              { display: list-item }
head            { display: none }
table           { display: table }
tr              { display: table-row }
thead           { display: table-header-group }
tbody           { display: table-row-group }
tfoot           { display: table-footer-group }
col             { display: table-column }
colgroup        { display: table-column-group }
td, th          { display: table-cell }
caption         { display: table-caption }
th              { font-weight: bolder; text-align: center }
caption         { text-align: center }
body            { margin: 8px }
h1              { font-size: 2em; margin: .67em 0 }
h2              { font-size: 1.5em; margin: .75em 0 }
h3              { font-size: 1.17em; margin: .83em 0 }
h4, p,
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu            { margin: 1.12em 0 }
h5              { font-size: .83em; margin: 1.5em 0 }
h6              { font-size: .75em; margin: 1.67em 0 }
h1, h2, h3, h4,
h5, h6, b,
strong          { font-weight: bolder }
blockquote      { margin-left: 40px; margin-right: 40px }
i, cite, em,
var, address    { font-style: italic }
pre, tt, code,
kbd, samp       { font-family: monospace }
pre             { white-space: pre }
button, textarea,
input, select   { display: inline-block }
big             { font-size: 1.17em }
small, sub, sup { font-size: .83em }
sub             { vertical-align: sub }
sup             { vertical-align: super }
table           { border-spacing: 2px; }
thead, tbody,
tfoot           { vertical-align: middle }
td, th, tr      { vertical-align: inherit }
s, strike, del  { text-decoration: line-through }
hr              { border: 1px inset }
ol, ul, dir,
menu, dd        { margin-left: 40px }
ol              { list-style-type: decimal }
ol ul, ul ol,
ul ul, ol ol    { margin-top: 0; margin-bottom: 0 }
u, ins          { text-decoration: underline }
br:before       { content: "\A"; white-space: pre-line }
center          { text-align: center }
:link, :visited { text-decoration: underline }
:focus          { outline: thin dotted invert }

/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"]  { direction: ltr; unicode-bidi: bidi-override }
BDO[DIR="rtl"]  { direction: rtl; unicode-bidi: bidi-override }

*[DIR="ltr"]    { direction: ltr; unicode-bidi: embed }
*[DIR="rtl"]    { direction: rtl; unicode-bidi: embed }

@media print {
  h1            { page-break-before: always }
  h1, h2, h3,
  h4, h5, h6    { page-break-after: avoid }
  ul, ol, dl    { page-break-before: avoid }
}

解决方法

在哪里可以找到浏览器的HTML元素默认CSS?

许多HTML元素都带有一些默认的CSS属性,这些属性有时会导致未知/有害的行为。例如,输入框在不同浏览器中的显示方式有所不同。我正在寻找一个涵盖新CSS3属性和新HTML5元素的地方。

我在其他(较旧的)问题(例如浏览器的默认CSS样式表中看到了答案,这些问题提出了CSS重置的解决方案。有时不需要这种解决方案,通常我实际上想保留一些基本属性(例如在Chrome中突出显示输入框)。换句话说:我不想仅仅因为我不知道它们在做什么而摆脱它们。

那么, 有没有一个网站可以为我提供所有(或可能最多)这些信息?

2013全面兼容多浏览器IE6?8&火狐&其他主流浏览器的CSS HACK写法_html/css_WEB-ITnose

2013全面兼容多浏览器IE6?8&火狐&其他主流浏览器的CSS HACK写法_html/css_WEB-ITnose

兼容性

为客户解决兼容性问题的同时记录下了解决方法,给大家分享分享。。。。

把这段代码放到里面,在ie8里面的页面解析起来就跟ie7一模一样的了,所以,基本上可以无视ie8,剩下的代码只需要这样写就可以了 
复制代码
代码如下:

background:#ffc; /* 对firefox有效*/ 
*background:#ccc; /* 对ie7有效 */ 
_background:#000; /* 只对ie6有效 */ 

解释一下吧: 

firefox能解析第一段,后面的两个因为前面加了特殊符号“*”和“_”,firefox认不了,所以只认background:#ffc,看到的是黄色; 

ie7前两短都能认,以最后的为准,所以最后解析是background:#ccc,看到的是灰色; 

ie6三段都能认,而且“_”这个只有ie6能认,所以最后解析是_background:#000,看到的是黑色 

阿门!已经是最简单和最好理解的写法了,如果你是google进来的,我可以很负责任的告诉你,这种方法是ok的,我测试过。 

ie8的那段兼容7的代码我也测试过了,在我现在的windos 7 测试版所带的ie8是没问题的,以后ie8正式版出来还管不管用就不知道了。 

ps:如果你发现按我这样写还是有问题的话,请查看一下你的html头,看看之前的内容是不是这样的标准写法 

nbsp;html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>


这个是现在比较规范的写法,如果你是用dreamweaver做页面的话,默认也是这种规范的,切记,非这种规范写法的,兼容性不能保证

回复讨论(解决方案)

外链有广告嫌疑...

那IE6不能识别属性选择器怎么办?


你这个岂不让IE8+都按照IE7模式显示?
这样不好吧,难道你觉得IE7-是最好的浏览器,无视IE8,IE9,IE10?

android – 如何调整instagram应用内浏览器的html / css布局?

android – 如何调整instagram应用内浏览器的html / css布局?

我一直在谷歌搜索,但找不到我的问题的线索.我有一个小网站(仅限html / css),在移动Chrome上看起来不错.但是在 Android 5.0上的Instagram应用程序内浏览器中,paddings出现了问题.有没有办法通过媒体查询或前缀来处理应用内浏览器?到目前为止,我一无所获.希望有人可以帮助我.提前致谢.

附:抱歉我的英语不好,我正在努力.

解决方法

您可以使用 JavaScript来检测包含Instagram的用户代理,并为该案例请求特定的CSS.

示例代码:

<script>
var isInstagram = navigator.userAgent.match(/instagram/i);
if (isInstagram) {
  var head = document.querySelector(''head'');
  var link = document.createElement(''link'');
  link.rel = ''stylesheet'';
  link.href = ''your-file-with-instagram-fixes.css'';
  head.appendChild(link);
}
</script>

css html元素居中与html元素内容居中的区别

css html元素居中与html元素内容居中的区别

div盒子居中

div居中是对框架盒子本身设置。让网页主体水平居中于浏览器中,就需设置margin:0 auto实现布局居中。

 

CSS 内容居中

和DIV盒子居中有着同样居中字眼的内容居中,则是对盒子里内容(文字、图片等内容)实现水平居中。使用text-align:center即可实现HTML元素里的内容居中。不管是对div标签、h1标签、h2标签、p标签等html元素标签设置都能让其对于盒子里内容水平居中。

立即学习“前端免费学习笔记(深入)”;

 

实例:

 
 
 
<title>css html元素居中与html元素内容居中的区别</title><div>码农教程</div><!--这里是DIV盒子相对于父级居中,盒子里面的内容并没有居中-->
<div>码农教程</div><!--这样是div盒子里面的内容相对于盒子本身居中-->
 
登录后复制

在线测试

 

小结:

  • html元素居中:对框架设置水平居中(比如对DIV本身设置DIV水平居中于浏览器中)。
  • html内容居中:对盒子里的内容设置水平居中(比如DIV内放到图片、文字等内容)

css – 为什么我的HTML元素之间会出现空格?

css – 为什么我的HTML元素之间会出现空格?

我正在为我的妈妈背包客业务设计一个网站.我遇到的问题是在我的横幅图像和导航栏之间有一条空白线,您可以在图像中看到.我认为这与保证金有关,所以我将它设置为零,两个元素都无济于事.

还有第二个问题 – 为什么我的黑色边框也不包括主要内容?我认为,因为它的身体背景,它会绕过身体的每个元素.

我意识到可能有类似的问题,但我无法在任何地方找到答案.我会感激任何人的意见 – 这是我在这里发表的第一篇文章,所以如果我搞砸任何格式,我很抱歉.

我的网站图片可以在这里找到:

http://postimage.org/image/20dhjcdb8/

提前致谢.

我目前在index.html文件中有以下代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
        <link rel="stylesheet" type="text/css" href="swaggeRSStyle.css">
            <title>Oamaru Backpackers Hostel,Swaggers Backpackers - Home</title>
        </head>


        <body>
        <img src="final.jpg" id="banner"></img>
        <ul id="nav">
            <li><a href="index.html">Home</a></li>
            <li><a href="planning.html">Planning</a></li>
            <li><a href="construction.html">Construction</a></li>
            <li><a href="evaluation.html">Evaluation</a></li>
        </ul>

        <div id="mainc">
        <p>Make Yourself at Home</p>
    <p>Swaggers Backpackers is a converted old house located within walking distance of all the best parts of Oamaru. Explore the old victorian era buildings and shops of the city centre,or see the penguin colonies down the street. Swaggers is owned and operated by camp mum Agra,who makes all guests feel welcome,informed,and perhaps a bit mothered. </p>

        </div>   

    </body>
    </html>

和以下CSS代码:

html{
    font-family: sans-serif;
    background-color:#464E54;
}

body{
    width: 960px;
    margin: auto;
    background-color: white;
    border: 5px solid black;
}

#banner{
    padding: 0px;
    margin: 0;
}

#nav {
    list-style-type: none;
    padding: 0px;
    margin: 0px;
    overflow: hidden;

}

#mainc {

    width: 960px;
    float: right;
    background-color: white;
    margin: 0;
}

.links {
    float: left;
    margin: 0px;
}

a:link,a:visited {

    display: block;
    width: 232px;
    font-weight: bold;
    color: grey;
    background-color: #dad8bf;
    text-align: center;
    padding: 4px;
    text-decoration: none;
    text-transform: uppercase;
    margin-top: 0px;
}

a:hover,a:active{

    background-color: #333333;
}

解决方法

The problem that I am having is between my banner image and my navbar there is a blank white line that you can see in the image. I thought this is to do with the margin so I have set it to zero for both of the elements to no avail.

在HTML图像中默认为内联级别元素,因此它们遵循文本规则(并且下面将有空白区域以保持与“p”等字母的正确对齐).您可以将display:block指定给标题图像,也可以将标题容器定义为与图像具有相同的精确高度

Also a second question – Why does my black border not cover the main content as well? I thought since its a body background it would go around every element in the body.

因为浮动元素从容器中弹出,所以必须清除浮动以使用类似的东西扩展容器

<div></div>

或者使用一些reset / clearfix css,例如html5boilerplate提供的css.

关于浏览器的HTML元素默认CSShtml默认浏览器怎么设置的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于2013全面兼容多浏览器IE6?8&火狐&其他主流浏览器的CSS HACK写法_html/css_WEB-ITnose、android – 如何调整instagram应用内浏览器的html / css布局?、css html元素居中与html元素内容居中的区别、css – 为什么我的HTML元素之间会出现空格?的相关信息,请在本站寻找。

本文标签: