本文将向大家介绍如何 利用 CSS3的新样式属性 制作 一个HT ML 5的 LOG o。我们先来看看最终的效果:
不要怀疑,上面的logo完全由HTML+CSS实现。我们将logo划分为盾形、数字5和 辐射 背景三大部分,下面将分别实现每个部分。
盾形
盾形在外形上是左右对称的,因此我们可先完成左 半 边,右半边可复制过来再修改一些参数。左半边准备用三个div实现,其中有两个div需要倾斜一定的角度来实现盾形的左边和底边,这里使用transform的skew来完成。代码如下(注意,这里只使用了 webkit 前缀的样式,仅在Ch rom e、Safari等Webk IT 内核浏览器支持):
XM L/HTML Code 复制内容到剪贴板
<!--&nbs p; left side --> < div class = "dark_orange" style = "left:32px;width:140px;h ei ght:346px;" > </ div > < div class = "dark_orange" style = "-webkit -t ransform:skewx(5 deg );left:16px;width:100px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewy(15deg);top:265px;left:32px;width:140px;height:100px;" > </ div > @H_ 304 _133@
其中,CSS样式定义所有div都是绝对定位,dark_orange类指定了一个橘色背景:
div{position:absolute}
.dark_orange{background: # e15016}
我们看一下效果:
下面我们再复制一遍HTML,修改一些参数作为盾形的右侧:
XML/HTML Code 复制内容到剪贴板
<!-- right side --> < div class = "dark_orange" style = "left:172px;width:140px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewx(-5deg);left:227px;width:100px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewy(-15deg);top:265px;left:172px;width:140px;height:100px;" > </ div >
效果如下:
盾形的右侧里面有浅色的区域,我们将盾的右侧复制一份通过scale缩小 一点 ,此外还需要 调整 一些样式属性:
XML/HTML Code 复制内容到剪贴板
<!-- inner --> < div style = "-webkit-transform:scale(0.82);left:31px;top:25px" > < div class = "light_orange" style = "left:172px;width:140px;height:346px;" > </ div > < div class = "light_orange" style = "-webkit-transform:skewx(-5deg);left:227px;width:100px;height:363px;" > </ div > < div class = "light_orange" style = "-webkit-transform:skewy(-15deg);top:282px;left:172px;width:138px;height:100px;" > </ div > </ div >
light_orange对应浅一点儿的背景色:
.light_orange{background:#ee6812}
盾形已经完成了:
数字5
数字5由若干div组成,倾斜的效果依旧通过skew来控制:
XML/HTML Code 复制内容到剪贴板
<!-- 5 --> < div class = "light_gray" style = "height:43px;width:102px;left:70px;top:70px" > </ div > < div class = "light_gray" style = "width:46px;height:216px;-webkit-transform:skewx(5deg);top:70px;left:75px;" > </ div > < div class = "light_gray" style = "height:43px;width:95px;left:77px;top:156px" > </ div > < div class = "light_gray" style = "height:47px;width:87px;left:85px;top:251px;-webkit-transform:skewy(15deg)" > </ div > < div class = "white" style = "height:43px;width:102px;left:172px;top:70px" > </ div > < div class = "white" style = "width:46px;height:216px;-webkit-transform:skewx(-5deg);top:70px;left:223px;" > </ div > < div class = "white" style = "height:43px;width:95px;left:172px;top:156px" > </ div > < div class = "white" style = "height:47px;width:87px;left:172px;top:251px;-webkit-transform:skewy(-15deg)" > </ div >
light_gray类和white类对应的样式:
.light_gray{background:#ebebeb}
.white{background:#fff}
我们看到如下效果:
为了最终实现数字5,我们需要在两个位置打两个[ 补丁 ]:
XML/HTML Code 复制内容到剪贴板
<!-- patch --> < div class = "dark_orange" style = "height:20px;top:199px;width:80px;left:60px;" > </ div > < div class = "light_orange" style = "height:43px;top:113px;width:100px;left:180px;" > </ div >
最终效果:
辐射背景
辐射背景主要使用rotate来完成,这里我贴出完整的代码:
XML/HTML Code 复制内容到剪贴板
<!DOCTY PE html > < html > < head > < meta charset = "utf-8" /> < title > HTML5 logo </ title > < style > div{position:absolute} .dark_orange{background:#e15016} .light_orange{background:#ee6812} .light_gray{background:#ebebeb} .white{background:#fff} .be am {width:1600px;height:20px;-webkit-transform-ori gin :800 10;top:290px;left:-400px} </ style > </ head > < body style = " ;m arg in:0;padding:0" > < div class = "bg" style = "width:800px;height:600px;background:# f2 f2f2;overflow:hidden" > < div class = "white beam" style = "-webkit-transform:rotate(5deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(15deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(25deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(35deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(45deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(55deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(65deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(75deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(85deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(95deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(105deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(115deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(125deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(135deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(145deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(155deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(165deg)" > </ div > < div class = "white beam" style = "-webkit-transform:rotate(175deg)" > </ div > < div class = "logo" style = "top:120px;left:229px;" > <!-- left side --> < div class = "dark_orange" style = "left:32px;width:140px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewx(5deg);left:16px;width:100px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewy(15deg);top:265px;left:32px;width:140px;height:100px;" > </ div > <!-- right side --> < div class = "dark_orange" style = "left:172px;width:140px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewx(-5deg);left:227px;width:100px;height:346px;" > </ div > < div class = "dark_orange" style = "-webkit-transform:skewy(-15deg);top:265px;left:172px;width:140px;height:100px;" > </ div > <!-- inner --> < div style = "-webkit-transform:scale(0.82);left:31px;top:25px" > < div class = "light_orange" style = "left:172px;width:140px;height:346px;" > </ div > < div class = "light_orange" style = "-webkit-transform:skewx(-5deg);left:227px;width:100px;height:363px;" > </ div > < div class = "light_orange" style = "-webkit-transform:skewy(-15deg);top:282px;left:172px;width:138px;height:100px;" > </ div > </ div > <!-- 5 --> < div class = "light_gray" style = "height:43px;width:102px;left:70px;top:70px" > </ div > < div class = "light_gray" style = "width:46px;height:216px;-webkit-transform:skewx(5deg);top:70px;left:75px;" > </ div > < div class = "light_gray" style = "height:43px;width:95px;left:77px;top:156px" > </ div > < div class = "light_gray" style = "height:47px;width:87px;left:85px;top:251px;-webkit-transform:skewy(15deg)" > </ div > < div class = "white" style = "height:43px;width:102px;left:172px;top:70px" > </ div > < div class = "white" style = "width:46px;height:216px;-webkit-transform:skewx(-5deg);top:70px;left:223px;" > </ div > < div class = "white" style = "height:43px;width:95px;left:172px;top:156px" > </ div > < div class = "white" style = "height:47px;width:87px;left:172px;top:251px;-webkit-transform:skewy(-15deg)" > </ div > <!-- patch --> < div class = "dark_orange" style = "height:20px;top:199px;width:80px;left:60px;" > </ div > < div class = "light_orange" style = "height:43px;top:113px;width:100px;left:180px;" > </ div > </ div > <!-- end of logo --> </ div > <!-- end of bg --> </ body > </ html >
HTML5的logo已经完成了!
以上就是小编为大家带来的用CSS3 打造 HTML5的Logo(实现代码)的全部内容了,希望大家多多支持脚步之家。
原文地址: http://HdhCmsTestcnblogs测试数据/androidshouce/archive/2016/06/16/5589780.html
@H_933_2 512 @总结
以上是 为你收集整理的 用CSS3打造HTML5的Logo(实现代码) 全部内容,希望文章能够帮你解决 用CSS3打造HTML5的Logo(实现代码) 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于用CSS3打造HTML5的Logo(实现代码)的详细内容...