html - 我如何做一个有超过 1 种背景颜色的网站?

标签 html css colors background

这就是我得到的,但这只是一种背景颜色,可以填充 90% 的屏幕。但我想在下面有另一种颜色。

position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 90%;
background-color: #20a2d6;}

你可以找到我想要得到的例子 here

最佳答案

http://www.spelltower.com/正在使用 HTML section那些彩色背景的标签。它不仅仅是具有多种背景颜色的单个元素。 Javascript 用于在调整浏览器窗口大小时调整每个部分的大小。

HTML

<div>
    <section id="first_section">First Section</section>
    <section id="second_section">Second Section</section>
    <section id="third_section">Third Section</section>
</div>

CSS

#first_section { background_color: blue; }
#second_section { background_color: red; }
#third_section { background_color: green; }

Javascript

//When the browser window is resized...
$(window).resize(function() {
    // Get the new window height
    var windowHeight = $(window).height();

    //Determine the height we want each section, in this
    //case we don't want it to be less than 600 pixels tall
    var newHeight = windowHeight;
    if(newHeight<600) newHeight = 600;

    $('section').css('height', newHeight);
});

关于html - 我如何做一个有超过 1 种背景颜色的网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27325972/

相关文章:

html - 如何在html中删除悬停图像的轮廓

WPF datagrid 单元格颜色取决于先前的单元格值

javascript - 如何为第二个列表项应用默认事件类

html - 为什么 CSS 中的绝对单位在不同的屏幕上显示的不是真正的绝对单位?

两个 Div 之间的 CSS 水平空间问题

html - 内联 div 填充宽度

java - 用额外的颜色按顺序给形状着色

java - 在 OpenCV (Java) 中获取正确的 HSV 颜色 inRange

javascript - Odoo:使用支付收单方添加 Stripe

html - Bootstrap 定制