html,css 同一个程序, 不同<!DOCTYPE> 头会出来有些标签对 , 多出几个像素来, 用h5的<!DOCTYPE>多了几个像素, 用html:xt的<!DOCTYE>头就跟预期的一样.
用h5的<!DOCTYPE>的头, 中间出来一条白色空白. 查看了每个标签的 padding margin border 都是正常的没有多出来的像素.
用html:xt的<!DOCTYPE>的头,中间就不会出现一条空白, 跟代码的预期一样.
pichost
大佬, 这是怎么回事啊, 帮我看看
- <!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" xml:lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- .cl {
- clear: both;
- }
- .nomargin {
- margin: 0 !important;
- }
- body {
- height: 4444px;
- font-size: 14px;
- font-family: "微软雅黑";
- }
- .inner_c {
- width: 1000px;
- margin: 0 auto;
- }
- .product{
- padding-top: 50px;
- height: 229px;
- border-bottom: 1px solid #DBE1E7;
- position: relative;
- }
- .product ul{
- list-style: none;
- }
- .product ul li{
- float: left;
- width: 218px;
- margin-right: 43px;
- }
- .product ul li.last{
- width: 217px;
- overflow: hidden;
- }
- .product ul li a{
- text-decoration: none;
- display: block;
- padding-bottom: 12px;
- }
- .product ul li a:hover{
- background-color: #38B774;
- }
- .product ul li span{
- /*转成块之后,就能用text-align:center;来居中内部文字了*/
- display: block;
- text-align: center;
- }
- .product ul li span.chinese{
- line-height: 40px;
- color:#444866;
- font-weight: bold;
- background-color: red;
- }
- .product ul li span.english{
- font-size: 12px;
- line-height: 12px;
- color:#38B774;
- background-color: yellow;
- }
- .product ul li a:hover span.chinese{
- color:white;
- }
- .product ul li a:hover span.english{
- color:white;
- }
- .product ul li span.english b{
- font-weight: normal;
- padding-right: 11px;
- background: url(https://i.postimg.cc/xChn7SkL/arrow.png) no-repeat right center;
- }
- .product ul li a:hover span.english b{
- background-image: url(https://i.postimg.cc/j2ftYkNm/arrow2.png);
- }
- .product .circles{
- position: absolute;
- bottom: -6px;
- left: 50%;
- width: 117px;
- height: 12px;
- background-color: white;
- margin-left: -59px;
- }
- .product ol{
- padding-left: 17px;
- list-style: none;
- }
- .product .circles ol li{
- float: left;
- width: 12px;
- height: 12px;
- background:url(https://i.postimg.cc/y63VRW5j/icons.png) no-repeat -1px -15px;
- margin-right: 14px;
- }
- .product .circles ol li.cur{
- background-position: -13px -15px;
- }
- </style>
- </head>
- <body>
- <div class="product inner_c">
- <ul>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN</b></span>
- </a>
- </li>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- <li class="nomargin last">
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- </ul>
- </div>
- </body>
- </html>
复制代码
湖北网友:朋友,你知道什么叫做不耻下问吗
宁夏网友:朋友,你知道什么叫做不耻下问吗
安徽网友:
在第48行后面加一条CSS语句:
- .product ul li a img {
- display: block;
- }
复制代码
内蒙古网友:朋友,你知道什么叫做不耻下问吗
海南网友:你根本不知道什么叫做不耻下问,就一文盲
浙江网友:目测楼主要被骂死
山西网友:朋友,你知道什么叫做不耻下问吗
福建网友:朋友,你知道什么叫做不耻下问吗
山东网友:虽然你不知道什么是不耻下问
但我还是帮你看了一下,我用Chrome、Firefox、IE都测试了,HTML5的<!DOCTYPE>没有任何问题,和html:xt都是一个效果
宁夏网友:你的意思是大佬们都不如你,然后你向大佬们提问,还想着大佬自愿回答你?
甘肃网友:你的意思是大佬们都不如你,然后你向大佬们提问,还想着大佬自愿回答你?
四川网友:朋友,你知道什么叫做不耻下问吗
山西网友:朋友,你知道什么叫做不耻下问吗
湖南网友:你这是瞧不起我薛某人
湖北网友:虽然我是萌新,但是我还是要说:
朋友,你知道什么叫做不耻下问吗
黑龙江网友:语文水平有点弱。。。。zsbd
湖北网友:好嚣张哇
江西网友:哈哈哈 这个词有印象 当年被我师傅教育了
吉林网友:可是多了一条空格, 你测试没有吗
浙江网友:没有,效果完全相同,我无法复现你那个空格的效果
贵州网友:没有,效果完全相同,我无法复现你那个空格的效果
山西网友:
应该是一样的,你再看看?// 其实添加了代码
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- .cl {
- clear: both;
- }
- .nomargin {
- margin: 0 !important;
- }
- body {
- height: 4444px;
- font-size: 14px;
- font-family: "微软雅黑";
- }
- .inner_c {
- width: 1000px;
- margin: 0 auto;
- }
- .product {
- padding-top: 50px;
- height: 229px;
- border-bottom: 1px solid #DBE1E7;
- position: relative;
- }
- .product ul {
- list-style: none;
- }
- .product ul li {
- float: left;
- width: 218px;
- margin-right: 43px;
- }
- .product ul li.last {
- width: 217px;
- overflow: hidden;
- }
- .product ul li a {
- text-decoration: none;
- display: block;
- padding-bottom: 12px;
- }
- .product ul li a:hover {
- background-color: #38B774;
- }
- /*添加的代码*/
- .product ul li img {
- display: block;
- }
- .product ul li span {
- /*转成块之后,就能用text-align:center;来居中内部文字了*/
- display: block;
- text-align: center;
- }
- .product ul li span.chinese {
- line-height: 40px;
- color: #444866;
- font-weight: bold;
- background-color: red;
- }
- .product ul li span.english {
- font-size: 12px;
- line-height: 12px;
- color: #38B774;
- background-color: yellow;
- }
- .product ul li a:hover span.chinese {
- color: white;
- }
- .product ul li a:hover span.english {
- color: white;
- }
- .product ul li span.english b {
- font-weight: normal;
- padding-right: 11px;
- background: url(https://i.postimg.cc/xChn7SkL/arrow.png) no-repeat right center;
- }
- .product ul li a:hover span.english b {
- background-image: url(https://i.postimg.cc/j2ftYkNm/arrow2.png);
- }
- .product .circles {
- position: absolute;
- bottom: -6px;
- left: 50%;
- width: 117px;
- height: 12px;
- background-color: white;
- margin-left: -59px;
- }
- .product ol {
- padding-left: 17px;
- list-style: none;
- }
- .product .circles ol li {
- float: left;
- width: 12px;
- height: 12px;
- background: url(https://i.postimg.cc/y63VRW5j/icons.png) no-repeat -1px -15px;
- margin-right: 14px;
- }
- .product .circles ol li.cur {
- background-position: -13px -15px;
- }
- </style>
- </head>
- <body>
- <div class="product inner_c">
- <ul>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN</b></span>
- </a>
- </li>
- <li>
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- <li class="nomargin last">
- <a href="#">
- <img src="https://i.postimg.cc/t4wZh8kn/pro1.png" alt="">
- <span class="chinese">四川麻将</span>
- <span class="english"><b>SICHUAN MAJIANG</b></span>
- </a>
- </li>
- </ul>
- </div>
- </body>
- </html>
复制代码
湖南网友:你有动代码吗
你考过了的是没有一条空白
我的代码就是有
山西网友:性感咩咩,在线扣分
朋友,你…….
福建网友:看了一下,我好像写错了,H5的头是<!doctype html>,我写成了<!doctype>,换成<!doctype html>的确出现了你所说的空行现象。
我看了代码,HTML5中img元素是inline显示的,而span元素是block显示的,HTML可能把换行符当作字符解析了。解决这一问题很多种方法,比如把img的显示改为block显示,添加以下代码
- .product ul li img {
- display: block;
- }
复制代码
山东网友:默认样式我到没太在意他, 我想把span转行内块, 没成功, 代码写错了, 啊哈哈哈哈哈哈哈
谢谢啊
内蒙古网友:不用谢,就当温习一下HTML和css基础知识吧,都忘光了
安徽网友:
在第48行后面加一条CSS语句:
- .product ul li a img {
- display: block;
- }
复制代码
未经允许不得转载:美国VPS_搬瓦工CN2 GIA VPS » 不耻下问我来了, 来来大佬帮我看看web这个代码,