开发者

What is preferred way to code when only header and footer's background is flexible only not content?

开发者 https://www.devze.com 2023-03-26 09:34 出处:网络
What is preferred way to code when only header and footer\'s background is flexible not content? Currently I use this method? Is there any better way to do this?

What is preferred way to code when only header and footer's background is flexible not content?

Currently I use this method? Is there any better way to do this?

<header style="background:red>
<div style="width:950px; margin:0 auto">
</div>
</header>

<div id="content" style="width:950px; margin:0 auto">

</div>


<footer style="background:blue>
<div style="width:950px; margin:0 auto">
</div>
</footer>
开发者_运维技巧

I used inline css just for example

actual mark-up is

 <header>
    <div id="header-inner">
    </div>
    </header>

    <div id="content">

    </div>


    <footer>
    <div id="footer-inner">
    </div>
    </footer>

I'm making website for Desktop and iPad both. iPad has fixed width but Desktop can be anything.

What is preferred way to code when only header and footer's background is flexible only not content?


header and footer make 100% width and content fix it a 95% width, so header and footer are flexible.

css:

header {
width:100%;
background:#ccc;
}

footer {
width:100%;
background:#ccc;
}

#content {
width:95%;
margin:0 auto;
}


Here's the other way of doing it. Not necessarily better. Your method looks fine.

<div class="wrapper">
    <header>
    </header>

    <div id="content">
    </div>

    <footer>
    </footer>
</div>

.wrapper { width: 950px; margin: 0 auto; }
header, footer { margin: 0px -9999px; padding: 0px 9999px; }


Why do you add another <div> in the header and footer?

Also please drop the inline css (if it isn't there just for this example).

Other than that your code looks fine with me

0

精彩评论

暂无评论...
验证码 换一张
取 消