2012-08-24 60 views
1

我是全新的CSS。我想让我的网页背景成为瑞典的旗帜。我可以出去导入一张图片,但是我想自己编码以便练习。我能够在页面上获得蓝色背景,但我怎样才能在国旗上制作黄金十字架?瑞典国旗 - 背景

+4

如果你想自己编码练习。然后尝试。当/如果你没有发布你试过的东西,我们会引导你朝着正确的方向发展。 http://www.whathaveyoutried.com? – Jeremy1026

+0

你有一点。我将在未来尝试做更多。 – Skitterm

回答

5

这里有一个尝试:little link。您可以在这里查看源代码:another little link。虽然这可能不完美!

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; 
} 

我希望这有助于以任何方式!

+0

聪明,一个很好的解决方案。做得好。 – MetalFrog

+0

这看起来不错。如果你不介意我问,身体究竟是什么:做完之后? – Skitterm

+0

'body:在'body'后面插入一个“虚拟”(不知何故)元素,并让你设计它。 – Chris

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/ 这是很基本的,但它会让你开始