带有“p”标签问题的 html css 列表
-
20-12-2019 - |
题
我们有很多列表(li 标签),后面紧跟着“p”标签。
<ul>
<li>
<p>in paragraph</p>
</li>
</ul>
在 IE8 中这不是问题。列表图像和文本已对齐。但在 IE10 中文本和列表图标未对齐(在兼容性视图中对齐)。
删除此类“p”标签是一种解决方案,但我们在很多地方都有它,所以这是不可能的。
我该如何解决?
真的会很感激。
我注意到这是因为“li”标签后面有“a”标签。但我无法删除它。html页面是自动生成的。
CSS:
html{color:#000;background:#FFF;}
body,div,h1,h2,h3,h4,h5,h6,pre,code,form,img{border:0;}
address,caption,cite,code,em,th{font-style:normal;font-weight:bold;}
caption,th{text-align:center;}
h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}
q:before,q:after{content:'';}
abbr,acronym{border:0;font-variant:normal;}
sup{vertical-align:text-top;}
sub{vertical-align:text-bottom;}
legend{color:#000;}
/* fonts */
select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif;}
table{font-size:inherit;font:100%;}
pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;}
html {background-color: white;
scrollbar-shadow-color: white;
scrollbar-highlight-color: white;
scrollbar-face-color: white;
scrollbar-3dlight-color: white;
scrollbar-darkshadow-color: white;
scrollbar-track-color: white;
scrollbar-arrow-color: white;}
Scrollbar hiding*/
body { font-family: arial;}
.familylinks {font-family: arial; padding-top:1.75em;}
.tablenoborder { margin: 0.5em;}
.tablecustom{margin-left:-0.4em;}
.p ol{margin-top: 0em;}
ul.simple { list-style-type: none }
ul { list-style-type: disc; list-style-position: outside; padding-bottom: 0.02em; margin-top:-0.05em;}/*--padding-bottom:0.15 changed to 0.05*/
ol li { margin-left: -1.05em; padding-bottom: 0.25em;}
ol li p{margin-top:-0.00005em;}
li p{margin-top:-0.00005em;padding-top:0em;color:red}
ol.customlists { margin-top: -0.5em}
ol.customlists { margin-top: -0.25em}
ol.h2custom{margin-top: 0.5em}
ol.olcustom{margin-left:2.6em;}
ul.ulcustom{margin-left:2.6em}
/* Various basic phrase styles */
.bold { font-weight: bold; }
.boldItalic { font-weight: bold; font-style: italic; }
.italic { font-style: italic; }
.underlined { text-decoration: underline; }
/* Align images based on @align on topic/image */
div.imageleft { text-align: left }
div.imagecenter { text-align: center; margin-top: 1em; margin-bottom: 1em; }
div.imageright { text-align: right }
div.imagejustify { text-align: justify }
html 文件示例:
<?xml version="1.0" encoding="UTF-8"?>
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="layout.css"/>
<title>Numbering & Bullets</title>
</head>
<body>
<h1>Numbering & Bullets</h1>
<div>
<div class="p"><strong>Bullets Test</strong>.</div>
<ul>
<li><a><!-- --></a>
<div><p>in paragraph</p></div>
</li>
<li><a><!-- --></a>blha blha blha
</li>
</div>
</body>
</html>
问候,RNV
解决方案
这是由于 div
, ,这是一个块,所以它想在内联之后开始一个新行 a
, ,即使 a
是空的(并且会被旧版本忽略)。
解决方案:关闭 div
放入内联块中,以便它与 a
, ,在它的右边。换句话说,将其添加到您的 CSS 中:
ul a + div {display:inline-block}
看 http://jsfiddle.net/MrLister/6RPsN/
编辑:或者如果你的一些 a
元素确实有内容,并且需要在后面的 div 上方占据自己的一行,添加 :empty
到 CSS,以便它仅适用于 a
没有内容。
ul a:empty + div {display:inline-block}
我不确定这是否适用于它应该适用的 IE 版本;无法在这里测试所有这些。
不隶属于 StackOverflow