css做 红色 的心的方法:首先创建一个HT ML 示例文件;然后定义一个div,并通过css属性画出一个 圆 形;接着 做出 一个正方形;最后通过css transform中的rotate属性实现爱心样式即可。
本教程操作环境:windows7系统、HTML5 && CSS3版、Dell G3 电 脑。
用css做一个爱心
摘要:HTML的标签都比较 简单 ,入门非常的迅速,但是CSS是一个需要我们深度挖掘的东西,里面的很多样式属性掌握几个常用的便可以实现很好看的效果,下面我便教大家如何用CSS做一个爱心。
前期预备知识:
明白正方形的画法。 明白圆形的画法。明白什么是定位。 明白怎么旋转。
话不多说,先教大家怎么用css画一个圆形。
.disc1{
width: 100px;
h ei ght: 100px;
border:1px solid red ;
background-color: red;
m arg in:300px 0px 0px 300px;
border-radius:100%;
float:left;
}由于我们的爱心是由两个圆和一个正方形组成的,所以我们还需要再来一个圆形。
.disc2{
width: 100px;
height: 100px;
border:1px solid red;
background-color: red;
mar gin :250px 0px 0px 0px;
border-radius:100%;
float:left;
pos IT ion: relative;
right: 50px;
}【推荐:《css视频教程》】
第三步我们就需要做一个正方形了。
.square{
width: 100px;
height: 100px;
border:1px solid red;
background-color: red;
margin: 300px 0px 0px 0px;
float: left;
position: relative;
right: 152px;
}做完这些的效果已经基本上出来了,但是我们还需要 调整 一下爱心的角度,这时就需要用到我们css样式中的transform中的rotate属性了。
我们由于需要把三个p都旋转角度,所以我们把这三个p放在一个p里面。具体代码如下:
.m ai n{
transform: rotate(45 deg );
margin: 300px;
}做到 现在,我们的爱心就已经做出来咯。效果图如下:
全部代码如下(包含HTML代码和CSS代码)
<!DOCTY PE html>
<html>
<head>
< ;m eta charset="utf-8" />
<link hr ef="css/square.css" rel="stylesheet" type="text/css">
<title></title>
</head>
<body>
<div class="main">
<div class="disc1"></div>
<div class="disc2"></div>
<div class="square"></div>
</div>
</body>
</html>*{
margin: 0px;
padding: 0px;
}
.main{
transform: rotate(45deg);
margin: 300px;
}
.disc1{
width: 100px;
height: 100px;
border:1px solid red;
background-color: red;
margin:300px 0px 0px 300px;
border-radius:100%;
float:left;
}
.disc2{
width: 100px;
height: 100px;
border:1px solid red;
background-color: red;
margin:250px 0px 0px 0px;
border-radius:100%;
float:left;
position: relative;
right: 50px;
}
.square{
width: 100px;
height: 100px;
border:1px solid red;
background-color: red;
margin: 300px 0px 0px 0px;
float: left;
position: relative;
right: 152px;
}以上就是css怎么做个红色的心的详细内容,更多请关注其它相关 文章 !
总结
以上是 为你收集整理的 css怎么做个红色的心 全部内容,希望文章能够帮你解决 css怎么做个红色的心 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did199416