Html 如何水平显示“div”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25919796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:43:48  来源:igfitidea点击:

How to display "divs" horizontally?

htmlcss

提问by Xiaojian

<div id="Content">
    <div id="loginContent"></div>
    <div id="signupContent"></div>
</div>

I have a root div here. I want to display the child divs horizontally. How to do this?

我这里有一个根 div。我想水平显示子div。这该怎么做?

采纳答案by DeFeNdog

You mean this?

你是这个意思?

#loginContent,
#signupContent {
    float: left;
    width: 50%;
}

or

#Content {
  text-align: center;
}

#loginContent,
#signupContent {
    display: inline-block;
}

回答by Sergey6116

Use inline-block Fiddle:

使用内联块小提琴

#loginContent, #signupContent {
display: inline-block;

}

}

or you can use float Fiddle:

或者你可以使用浮动小提琴

#signupContent {
float: right;

}

}