Heim  >  Artikel  >  Web-Frontend  >  div设置inlineblock后,再设置margin,ie6 7里面input不能靠边什么原因?_html/css_WEB-ITnose

div设置inlineblock后,再设置margin,ie6 7里面input不能靠边什么原因?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:25:241320Durchsuche

input也会有margin了。为什么会是这样的?

<!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"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style type="text/css">.yi { border: 1px solid #000; display: inline-block; margin-left: 50px; }</style></head><body><div class="yi"> <input name="" type="text" /></div></body></html>


回复讨论(解决方案)

display: inline-block;

这个就是原因,这样设置,可以使得div拥有布局,ie67下的很多bug都是由布局引起的。

至于,为啥这个设置,会影响input元素(input元素在ie67本身就拥有布局)
我自己测试了下,这个情况只有在父子元素都拥有布局,并且子元素还是input和textarea这两个本身拥有布局的元素时,才会出现继承父元素的margin-left属性,这真是不理解了!!


期待高人现身!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn