简体   繁体   English

HTML定位

[英]HTML positioning

I thought that elements aren't fixed by default in HTML? 我以为HTML中的元素默认不是固定的? But everything I put on my page (except my header) won't move when I resize the browser window... How come? 但是,当我调整浏览器窗口的大小时,我放在页面上的所有内容(标题除外)都不会动...怎么回事?

I want it to be the other way round! 我希望它反过来! (The header should stay fixed, and the rest of the elements should be able to move). (标题应该保持固定,其余元素应该可以移动)。

I didn't use any position commands in my css style sheet. 我没有在CSS样式表中使用任何位置命令。

I only used this for example : 我仅以这个为例:

.container2 {
    width: 1200px;
    height: 480px;
    margin-top: 60px;
    margin-left: 100px;
    margin-bottom: 0;
}

My jsfiddle: http://jsfiddle.net/richirich/68Cnd/ 我的jsfiddle: http : //jsfiddle.net/richirich/68Cnd/

(Yes, I'm new to html, so pardon my dirty code). (是的,我是html的新手,请原谅我的肮脏代码)。

If you have multible little div's and you want that the div's use the whole place (horizontal) you can use: 如果您有多个小div,并且希望div使用整个位置(水平),则可以使用:

float: left

If you have one big div and you want that the div resize himself by resize the browser you have to use for example: 如果您有一个大div,并且希望div通过调整浏览器大小来调整自身大小,则必须使用例如:

width: 80%

Just add position:fixed; 只需添加position:fixed; to #header 到#header

You can start from here: http://jsfiddle.net/68Cnd/1/ . 您可以从这里开始: http : //jsfiddle.net/68Cnd/1/ Removed the body fixed width, and replaced containers width with max-width 除去body固定的宽度,并更换容器widthmax-width

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

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