1

I am brand new to CSS. I want to make the background of my web page the flag of Sweden. I could probably go out and import an image, but I wanted to code it up myself for practice. I am able to get the blue background on the page, but how would I go about making the gold cross on the flag?

4

2 回答 2

5

这是一个尝试:小链接。您可以在此处查看源代码:另一个小链接。不过,这可能并不完美!

CSS用于创建:

html, body {
    height: 100%;
    width: 100%;
}
body {
    background-color: blue;   
}
body:after {
    position: absolute;
    content: '';
    height: 100%;
    width: 10%;
    top: 0px;
    left: 25%;
    margin-left: -5%;
    background-color: yellow;    
}
body:before {
    position: absolute;
    content: '';
    width: 100%;
    height: 10%;
    top: 50%;
    left: 0px;
    margin-top: -5%;
    background-color: yellow;  
}

我希望以任何方式有所帮助!

于 2012-08-24T18:07:47.320 回答
0

你必须这样做

.flag-background { position: relative; background: blue; width: 150px; height: 100px; }
.horiz-cross { width: 100%; height: 10px; background: yellow; position: absolute; top: 50px; }
.vert-cross { height: 100%; width: 10px; left: 50px; background: yellow;position: absolute}​

​<div class="flag-background">
<div class="horiz-cross"></div>
<div class="vert-cross"></div>
</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​

http://jsfiddle.net/chadpeppers/sYeTq/ 这是非常基本的,但它会让你开始

于 2012-08-24T18:07:35.183 回答