Css 瑞典国旗——背景
我是全新的CSS。我想把我的网页背景做成瑞典国旗。我可能会出去导入一个图像,但我想自己编写代码以便练习。我可以在页面上看到蓝色的背景,但是我该如何在国旗上画金色的十字架呢 你必须这样做Css 瑞典国旗——背景,css,Css,我是全新的CSS。我想把我的网页背景做成瑞典国旗。我可能会出去导入一个图像,但我想自己编写代码以便练习。我可以在页面上看到蓝色的背景,但是我该如何在国旗上画金色的十字架呢 你必须这样做 .flag-background { position: relative; background: blue; width: 150px; height: 100px; } .horiz-cross { width: 100%; height: 10px; background: yellow; positio
.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>
.flag background{位置:相对;背景:蓝色;宽度:150px;高度:100px;}
.horiz交叉{宽度:100%;高度:10px;背景:黄色;位置:绝对;顶部:50px;}
垂直交叉{高度:100%;宽度:10px;左侧:50px;背景:黄色;位置:绝对}
这是非常基本的,但它会让你开始你必须这样做
.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>
.flag background{位置:相对;背景:蓝色;宽度:150px;高度:100px;}
.horiz交叉{宽度:100%;高度:10px;背景:黄色;位置:绝对;顶部:50px;}
垂直交叉{高度:100%;宽度:10px;左侧:50px;背景:黄色;位置:绝对}
这是非常基本的,但它会让您开始这里有一个尝试:。您可以在此处查看源:。不过,这可能并不完美
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;
}
我希望这对我有所帮助 这里有一个尝试:。您可以在此处查看源:。不过,这可能并不完美
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;
}
我希望这对我有所帮助 如果你想自己编写代码来练习。然后试试看。当/如果您失败,请发布您尝试过的内容,我们将为您指引正确的方向?你说得对。如果你想自己编写代码来练习的话,我以后会尝试做更多。然后试试看。当/如果您失败,请发布您尝试过的内容,我们将为您指引正确的方向?你说得对。我将来会尝试做更多。聪明,一个很好的解决方案。干得好,看起来很棒。如果您不介意我问一下,body:after究竟做什么?
body:after
在body
之后插入一个“虚拟”(不知何故)元素,并允许您对其进行样式设置。因此,它不需要创建html元素即可工作。整洁的聪明,是一个很好的解决方案。干得好,看起来很棒。如果您不介意我问一下,body:after究竟做什么?body:after
在body
之后插入一个“虚拟”(不知何故)元素,并允许您对其进行样式设置。因此,它不需要创建html元素即可工作。整洁的