Chodzi po prostu o to, że chcę stworzyć "ludzika" używając tylko css3. Już przy tworzeniu głowy napotkałem taki problem, że źrenice, czyli "<p>" przetrzymujące literkę "o" nie chce wylądować w "divie" o nazwie "eye", tylko ląduje pod nim. Domyslam się, że coś z "positionami: jest tu nie tak u mnie. Proszę o pomoc.
Oto kod:
body{
margin:0 auto;
text-align:center;
padding:0;
}
#outer{ /*box with head and eyes */
overflow:hidden;
width: 102px;
margin:0 auto;
border: 1px black solid;
}
#head{ /* head */
position:relative;
-moz-border-radius: 220px;
-webkit-border-radius: 220px;
-o-border-radius: 220px;
width: 100px;
height: 100px;
background: yellow;
}
.eye{ /* eye */
position:absolute;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
width: 20px;
height: 16px;
background: white;
border: 1px black solid;
text-align:center;
}
#left{ /* positioning left eye */
margin: 22px 0 0 15px;
}
#right{ /* positioning right eye */
margin: 22px 15px 0 60px;
}
.appleoftheeye{ /* to jest źrenica, w tym wypadku literka "o" */
font-size:15px;
font-weight:bold;
}
#mouth{ /* usta */
position:absolute;
-moz-border-radius: 0 0 69px 69px;
width: 66px;
height: 22px;
background: white;
border: 1px black solid;
margin: 66px 0 0 15px;
}
A to kod html:
<body>
<div id="outer">
<div id="head">
<div class="eye" id="left"> <p class="appleoftheeye">o</p> </div>
<div class="eye" id="right"> <p class="appleoftheeye">o</p> </div>
<div id="mouth"></div>
</div>
</div>
</body>
Jeszcze pytanie: Czy można napisać tą glowę bardziej prostym kodem? Np. za pomocą "relative" i "z-index"? Czy mój sposób jest najprostszy?
Ten post edytował Teppic 3.04.2012, 19:41:47