Put login form to the right of the page

。_饼干妹妹 提交于 2019-12-13 13:15:22

问题


Here is my jsFiddle. Despite the fact that I am applying this rule

#login {
    float: right;
}

the form will stay next to Leaderboard link. In a mobile, this is not a problem, since everything will be displayed in a one column fahsion, but in a desktop I would like the logo to be to leftmost position, the textbox and Leaderboard to be somewhere in the center and the login to the rightmost position.

What am I missing?


Notice that with the actual logo everything is fine (with regards to the logo), so ignore the ugly effect the linked logo has in the example.


回答1:


Display flex is applied to parent element (ui-block-solo). It would be better not to use display flex, float alignment and position absolute at the same time.

If you choose to keep display flex, you can use flex alignment - you can read more here https://css-tricks.com/snippets/css/a-guide-to-flexbox/.

If there is float alignment and position absolute, position absolute will be applied. Furthermore if you prefer float alignment or position absolute you should use media queries for mobile devices.




回答2:


You are using display: flex in the parent div .ui-block-solo. Float has no effect on flex items.




回答3:


Try using the grid system of Bootstrap in order to position your elements. http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

For example you can have something like this: http://www.codeply.com/go/UVfJSRytc2

FYI Bootstrap's grid system is really easy to use and it saves you a lot of time from working with plain CSS. With the grid you actually split the screen in rows and columns and you can easily place your elements anywhere you want. I suggest you take a look at it for future reference :)



来源:https://stackoverflow.com/questions/32475724/put-login-form-to-the-right-of-the-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!