简体   繁体   English

如何将锚元素的宽度限制为其子元素的宽度(h1和h2)

[英]How to limit width of anchor element to width of his child elements (h1 and h2)

Ok i have div with id "logo" inside div i have h1 and h2 element and i have problem to anchor them... If i put anchor inside h1 or h2 width is same as text width but i have space between h1 and h2 which not belong to link.. 好的,我在div内有id为“ logo”的div,我有h1和h2元素,我在锚定它们时遇到了问题...如果我将锚定放在h1或h2内,宽度与文本宽度相同,但是在h1和h2之间有空格不属于链接

If i wrap h1 and h2 inside of achor its ok but width take full width of header element (parent of all elements i mentioned) 如果我将h1和h2包裹在achor内部,可以,但宽度取标头元素的全宽(我提到的所有元素的父元素)

I also tried to put h1 and h2 inside of anchor element (without using div) but it took full width of header (i used display block, not working) 我还尝试将h1和h2放在锚点元素内(不使用div),但是它占用了标头的全宽度(我使用了显示块,无法正常工作)

Try this fiddle here 在这里尝试这个小提琴

In this fiddle just added 在这个小提琴中刚刚添加

.header{
     text-align: center;
  } 

#logo{
    display: inline-block;
  }

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

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