简体   繁体   English

CSS显示:内联不起作用

[英]css display: inline not working

I am trying to display the each of the elements of 'headeri' in a horizontal manner, I've attached the js with it, if it's any help. 我试图以水平方式显示“ headeri”的每个元素,如果有帮助,我已经将js附加了它。 I've tried to add the class and id name (both of them, in turn) to the css file using a tag and img tag (both of them, in turn), but to no avail. 我试图使用标签和img标签(依次是它们)将类和id名称(依次是它们)都添加到css文件中,但无济于事。

 var loaded = false; function loadImages(){} function react(img, plain){} function loadImages() { img1plain = new Image(0,0); img1plain.src = 'plain1.gif'; img1over = new Image(0,0); img1over.src = 'over1.gif'; img2plain = new Image(0,0); img2plain.src = 'plain2.gif'; img2over = new Image(0,0); img2over.src = 'over2.gif'; img3plain = new Image(0,0); img3plain.src = 'plain3.gif'; img3over = new Image(0,0); img3over.src = 'over3.gif'; loaded = true; } function react(img, plain) { if (loaded) { if (plain) document[img].src = eval(img + "plain.src"); else document[img].src = eval(img + "over.src"); } } 
 .headeri{ display: inline-block; } 
 <header> <A HREF="#top" class="headeri" onMouseOver="react('img1', false);return true" onMouseOut="react('img1', true);return true"><IMG SRC="plain1.gif" NAME="img1" WIDTH=150 HEIGHT=25 BORDER=0></A><BR> <A HREF="#top" class="headeri"onMouseOver="react('img2', false);return true" onMouseOut="react('img2', true);return true"><IMG SRC="plain2.gif" NAME="img2" WIDTH=150 HEIGHT=25 BORDER=0></A><BR> <A HREF="#top" class="headeri"onMouseOver="react('img3', false);return true" onMouseOut="react('img3', true);return true"><IMG SRC="plain3.gif" NAME="img3" WIDTH=150 HEIGHT=25 BORDER=0></A><BR> </header> 

Remove <BR> Tag 删除<BR>标签

 var loaded = false; function loadImages(){} function react(img, plain){} function loadImages() { img1plain = new Image(0,0); img1plain.src = 'plain1.gif'; img1over = new Image(0,0); img1over.src = 'over1.gif'; img2plain = new Image(0,0); img2plain.src = 'plain2.gif'; img2over = new Image(0,0); img2over.src = 'over2.gif'; img3plain = new Image(0,0); img3plain.src = 'plain3.gif'; img3over = new Image(0,0); img3over.src = 'over3.gif'; loaded = true; } function react(img, plain) { if (loaded) { if (plain) document[img].src = eval(img + "plain.src"); else document[img].src = eval(img + "over.src"); } } 
 .headeri{ display: inline-block; } 
 <header> <A HREF="#top" class="headeri" onMouseOver="react('img1', false);return true" onMouseOut="react('img1', true);return true"><IMG SRC="plain1.gif" NAME="img1" WIDTH=150 HEIGHT=25 BORDER=0></A> <A HREF="#top" class="headeri"onMouseOver="react('img2', false);return true" onMouseOut="react('img2', true);return true"><IMG SRC="plain2.gif" NAME="img2" WIDTH=150 HEIGHT=25 BORDER=0></A> <A HREF="#top" class="headeri"onMouseOver="react('img3', false);return true" onMouseOut="react('img3', true);return true"><IMG SRC="plain3.gif" NAME="img3" WIDTH=150 HEIGHT=25 BORDER=0></A> </header> 

Remove the <br> behind each of your <a> tags - those are where your line breaks come from, not the CSS. 删除每个<a>标记后面的<br> -这些是换行符的来源,而不是CSS。

Also, a elements default to inline display, so unless you need the block rendering (for example for margins), you can just use the default display by not setting it explicitly, and your links will be in one line. 此外, a元素默认内嵌显示,所以,除非你需要的块渲染(例如用于边距),你可以通过未明确设置它使用默认的显示,你的链接将成为一条线。

Please remove the br tags and check it again. 请删除br标签,然后再次检查。

<header>
    <A HREF="#top" class="headeri" onMouseOver="react('img1', false);return true" onMouseOut="react('img1', true);return true"><IMG SRC="plain1.gif" NAME="img1" WIDTH=150 HEIGHT=25 BORDER=0></A>
    <A HREF="#top" class="headeri"onMouseOver="react('img2', false);return true" onMouseOut="react('img2', true);return true"><IMG SRC="plain2.gif" NAME="img2" WIDTH=150 HEIGHT=25 BORDER=0></A>
    <A HREF="#top" class="headeri"onMouseOver="react('img3', false);return true" onMouseOut="react('img3', true);return true"><IMG SRC="plain3.gif" NAME="img3" WIDTH=150 HEIGHT=25 BORDER=0></A>
</header>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM