css3练习:苹果笔记本电脑(有键盘和无键盘)

今天看到一句我最喜欢的名言,和大家分享一下。

周恩来说:世界上最聪明的人是最老实的人,因为只有老实人才能经得事实和历史的考验。

下面再和大家分享一下今天的CSS3例子,一个最有立体感的苹果笔记本电脑。

在学习CSS3时,一定要自己敲代码。不要抄。这样才能慢慢学会CSS3知识。

<div class="macbook">

    <div class="screen"></div>

    <div class="base"></div>

</div>

body {

    margin: 0;

    height: 100vh;

    display: flex;

    align-items: center;

    justify-content: center;

    background-image: linear-gradient(black, gray, silver, gray, black);

}

.macbook {

    font-size: 10px;

    width: 50em;

    display: flex;

    flex-direction: column;

    align-items: center;

}

.screen {

    width: 40em;

    height: calc(40em*0.667);

    box-sizing: border-box;

    border: black solid;

    border-width: 1.8em 1.3em 1.7em 1.3rem;

    border-radius: 3% 3% 0 0 / 5%;

    box-shadow: 0 0 0 0.1em silver;

    background: radial-gradient( circle at right bottom, rgba(255, 255, 255, 0.4) 33em, rgba(255, 255, 255, 0.6) 33em), black;

}

.base {

    width: inherit;

    height: 1.75em;

    /*border:2px solid yellow;*/


    --bottom: linear-gradient( white 55%, #999 60%, #222 90%, rgba(0, 0, 0, 0.1) 100%);

    border-radius: 0 0 10% 10% / 0 0 50% 50%;

    --top: linear-gradient( to right, hsla(0, 0%, 0%, 0.5) 0%, hsla(100, 100%, 100%, 0.8) 1%, hsla(0, 0%, 0%, 0.4) 4%, transparent 15%, hsla(100, 100%, 100%, 0.8) 50%, transparent 85%, hsla(0, 0%, 0%, 0.4) 96%, hsla(100, 100%, 100%, 0.8) 99%, hsla(0, 0%, 0%, 0.5) 100%) no-repeat top/100% 55%;

    background: var(--top), var(--bottom);

}

.base::before {

    content: '';

    position: absolute;

    width: 7em;

    height: 0.7em;

    /*border:2px solid dodgerblue;*/


    border-radius: 0 0 7% 7% / 0 0 95% 95%;

    left: calc(50% - 7em/2);

    box-shadow: inset -0.5em -0.1em 0.3em rgba(0, 0, 0, 0.2), inset 0.5em 0.1em 0.3em rgba(0, 0, 0, 0.2);

    background-color: #ddd;

}

再来一个我写的综合例子,一个带键盘的苹果笔记本电脑

<div class="macbook">

    <div class="screen">

        <div class="s_txt">MacBook Pro</div>

    </div>

    <div class="kbd">

        <div class="stoma"></div>

        <div class="keys">

            <ul class="row row1">

                <li class="esc">esc</li>

            </ul>

            <ul class="row row2">

                <li>~</li>

                <li>1</li>

                <li>2</li>

                <li>3</li>

                <li>4</li>

                <li>5</li>

                <li>6</li>

                <li>7</li>

                <li>8</li>

                <li>9</li>

                <li>0</li>

                <li>-</li>

                <li>=</li>

                <li class="delete">×</li>

            </ul>

            <ul class="row row2">

                <li>→|</li>

                <li>Q</li>

                <li>W</li>

                <li>E</li>

                <li>R</li>

                <li>T</li>

                <li>Y</li>

                <li>U</li>

                <li>I</li>

                <li>O</li>

                <li>P</li>

                <li>[</li>

                <li>]</li>

                <li>\</li>

            </ul>

            <ul class="row row2">

                <li class="back">中/英</li>

                <li>A</li>

                <li>S</li>

                <li>D</li>

                <li>F</li>

                <li>G</li>

                <li>H</li>

                <li>J</li>

                <li>K</li>

                <li>L</li>

                <li>;</li>

                <li>'</li>

                <li class="back">↩︎</li>

            </ul>

            <ul class="row row2">

                <li class="shift">⇧</li>

                <li>Z</li>

                <li>X</li>

                <li>C</li>

                <li>V</li>

                <li>B</li>

                <li>N</li>

                <li>M</li>

                <li>,</li>

                <li>。</li>

                <li>/</li>

                <li class="shift">⇧</li>

            </ul>

            <ul class="row row2">

                <li>fn</li>

                <li>^</li>

                <li>⌥</li>

                <li>⌘</li>

                <li class="space"></li>

                <li>⌘</li>

                <li>⌥</li>

                <li>◀</li>

                <li class="arw"></li>

                <li>►</li>

            </ul>

        </div>

        <div class="stoma"></div>

        <div class="base"></div>

    </div>

</div>

body {

    margin: 0;

    height: 100vh;

    display: flex;

    align-items: center;

    justify-content: center;

    background-image: linear-gradient(black, gray, silver, gray, black);

}

ul,li{list-style: none;}

.macbook {

    font-size: 10px;

    width: 50em;

    display: flex;

    flex-direction: column;

    align-items: center;

}

.macbook *::before,

.macbook *::after{

    content:'';

    position: absolute;

}

.screen{

    width: 40em;

    height: calc(45em*0.667);

    box-sizing: border-box;

    border: black solid;

    border-width: 1.8em 1.3em 1.7em 1.3rem;

    border-radius: 3% 3% 0 0 / 5%;

    box-shadow: 0 0 0 0.1em silver;

    transform: rotatex(-45deg);

    background: radial-gradient( circle at right bottom, rgba(255, 255, 255, 0.4) 33em, rgba(255, 255, 255, 0.6) 33em), black;

}

.screen::before{

    margin: -13px auto;

    width: 5px;

    height: 5px;

    border-radius: 50%;

    background: #00E676;

    animation: webcam 1000ms linear 800ms infinite;

    left: calc(50% - 5px/2);

}

.screen::after{

    left: 0;

    right: 0;

    margin:0 auto;

    bottom: -48px;

    left: -23px;

    width: 30rem;

    height: 36px;

    background: #111;

    border-radius: 0 0 12px 12px;

    border-left: 2px solid silver;

    border-right: 2px solid silver;

    border-bottom: 2px solid silver;

}

.s_txt{

    position: absolute;

    left: 0;

    right: 0;

    margin:0 auto;

    position: absolute;

    font-size: 14px;

    color: #999;

    bottom: -32px;

    left: 42%;

    z-index: 99;

}

@keyframes webcam{

    0%,10%,31%,60%,100% {

        background: #a6a6a6;

    }

    11%,30%,61%,99% {

        background: #00E676;

    }

}

.kbd{

    display: flex;

    flex-direction: row;

    z-index: 1;

    padding: 30px 5px 0em 5px;

    margin-top: -36px;

    width: 460px;

    height: 295px;

    background: silver;

    border-radius: 16px;

    position: relative;

    justify-content: center;

    box-shadow: 0 0 3px rgba(255, 255, 255, 0.5) inset

}

.kbd::before{

    top: 0;

    left: 0;

    right: 0;

    margin:0 auto;

    width: 340px;

    height: 9px;

    background: #222;

    box-shadow: 0 0 6px rgba(0, 0, 0, 0.7) inset;

}

.kbd::after{

    left: 0;

    right: 0;

    margin:0 auto;

    bottom: 10px;

    border-radius: 6px;

    border: 1px solid #999;

    width: 15em;

    height: 7.5em;

    background: silver;

}

.stoma{

    margin-top: 6px;

    width: 22px;

    height: 158px;

    background: radial-gradient(#555 26%, transparent 0);

    background-size: 3px 3px;

}

.keys{

    display: flex;

    flex-direction: column;

    margin: 0 5px 0 5px;

    width: 400px;

    height: 184px;

    box-shadow: inset 0 0 9px rgba(0, 0, 0, 0.3);

    border-radius: 4px;

}

.row{

    display: flex;

    flex-direction: row;

    justify-content: space-between;

    padding: 7px 5px 0 5px;

    border-radius: 3px;

    width: 380px;

    margin:0 auto;

}

.row1{background-color: #232323;margin-top:5px;padding-top: 3px;}

.row2{padding:7px 3px 0 3px;width:390px;}

.row li{

    color: white;

    background: #111;

    border-radius: 2px;

    box-shadow: 0 0 0 1px black;

    height: 22px;

    width: 22px;

    font-size: 7px;

    display: flex;

    justify-content: center;

    align-items: center;

    font-weight: bold;

    font-family: sans-serif;

}

.row1 li{

    background:#525358;

    color:#dddee2;

    border-radius: 2.25px;

    padding:0 3px;

    margin-bottom:3px;

}

.row2 li.delete,.row2 li.contrl{

    width:36px;

}

.row2 li.back{

    width: 40px;

}

.row2 li.shift{

    width: 50px;

}

.row2 li.space{

    width: 140px;

}

.row2 li.arw::before{

    content:'▴';

    width:22px;

    text-align: center;

    display: block;

    padding-bottom: 10px;

}

.row2 li.arw::after{

    content:'▾';

    width:22px;

    text-align: center;

    display: block;

    padding-top: 10px; 

}

.base{

    width: 7em;

    height: 0.3em;

    border-radius: 7% 7% 0 0 /  95% 95% 0 0;

    left: calc(50% - 7em/2);

    background-color: #000;

    position: absolute;

    bottom:0;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 221,548评论 6 515
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,497评论 3 399
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 167,990评论 0 360
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,618评论 1 296
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,618评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,246评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,819评论 3 421
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,725评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,268评论 1 320
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,356评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,488评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,181评论 5 350
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,862评论 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,331评论 0 24
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,445评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,897评论 3 376
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,500评论 2 359

推荐阅读更多精彩内容