当前位置: 动力学知识库 > 问答 > 编程问答 >

html - Aligning two elements in a container using css?

问题描述:

I like to make my navigation bar and header all the same, but I can't get the navigation bar to align properly. Using float: right doesn't work, as it appears to take it out of the container (if that makes sense)

My code is here: https://jsfiddle.net/AVY7T/228/

网友答案:

Did you add float: right to your element? As you said, floating will make the parent element ignore the element height, which places the element outside the parent. Adding overflow: hidden; to the parent element, in this case the header class, will solve the problem.

Updated JSFiddle:

https://jsfiddle.net/AVY7T/231/

Placing both elements on the same row:

https://jsfiddle.net/AVY7T/232/

分享给朋友:
您可能感兴趣的文章:
随机阅读: