html - How to style 3 (div) boxes using CSS -
i have html page:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>title</title> <link rel="stylesheet" href="stylebox.css"> <script src="script.js"></script> </head> <body> <div> <div> <div> text </div> </div> </div> </body> </html>
this page should - http://pasteboard.co/nflmljzpg.png
i have tried something, not know hot style text inside third div without editing html page
my css:
div { width: 380px; height: 300px; background: #b0cde9; border-style: solid; border-color: black; border-width: 1px; } div div { width: 290px; height: 280px; background: yellow; margin-left: 45px; margin-top: 8px; } div div div { width: 120px; height: 140px; background: #82c940; margin-top: 70px; }
(my boxes - http://pasteboard.co/nfo7mv7r7.png ) advise me please?
since don't want change html code, can apply padding third div position text inside it. need adjust width , height of div when add padding. example, if div has width of 120 px , want text 20px away left border, give left padding of 20px , decrease width 20px. thus, have div width 100px , padding left 20px. see example below.
html
<div> <div> <div> text </div> </div> </div>
css
div { width: 380px; height: 300px; background: #b0cde9; border-style: solid; border-color: black; border-width: 1px; } div div { width: 290px; height: 280px; background: yellow; margin-left: 45px; margin-top: 8px; } div div div { width: 100px; height: 60px; background: #82c940; margin-top: 70px; padding-top:80px; padding-left:20px; }
Comments
Post a Comment