简体   繁体   English

如何获得一个元素以匹配另一个元素的宽度?

[英]how can I get an element to match the width of another element?

So i'm making a webpage... 所以我正在制作一个网页...

view here... www.girlzwithmoustaches.com/home2 在这里查看... www.girlzwithmoustaches.com/home2

I have a top social media icon banner which i made inside of a "header"... 我有一个在“标题”中制作的顶级社交媒体图标横幅...

The css is below.. Now i want the top banner to match the width % of the image below... So when the user resizes the window, or based upon their browser window size, the top banner of the social media icons will stay aligned with the right most portion of the image slideshow below it.. css在下面。现在,我希望顶部横幅与下面图像的宽度%相匹配...因此,当用户调整窗口大小或基于其浏览器窗口大小时,社交媒体图标的顶部横幅将保留与下面的图像幻灯片的最右边部分对齐。

please help. 请帮忙。 how can i do this.. The social media icons are a basic ul with li and 我该怎么办..社交媒体图标是基本的ul,带有li和

 #headerwhat {
position: absolute;
top: 30px;
left:100px;
width: 70%;
height: auto;
vertical-align: middle;
horizontal-align: middle;

}

.smbanner {
width: 200px;
height: 50px;
position: relative;
float:right;
top: 0px;
left: 0px;

}

.smicons {
display: inline-block;
padding: 3px;
}

You have to use the same percentages if you want the widths to match. 如果要使宽度匹配,则必须使用相同的百分比。

So, if you have width: 70% for #headerwhat , the only way to get them to dynamically resize together is to set .smbanner 's width to 70% . 因此,如果您有width: 70% #headerwhat width: 70% ,则使它们一起动态调整大小的唯一方法是将.smbannerwidth设置为70%

Is that what you're asking? 那是你要的吗

将图片放在标题内,并为顶部横幅提供100%的宽度

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

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