简体   繁体   中英

How to extend a child element when parent element has padding inside?

Say I have a parent div with padding and a child div inside the parent div:

 .a { width: 200px; height: 200px; padding: 10px; background-color: green; } .b { background-color: yellow; }
 <div class='a'> <div class='b'>Hello</div> </div>

How can I make the child div align with the left edge of the parent, with padding present? Class a cannot be changed.

 .a { width: 200px; height: 200px; padding: 10px; background-color: green; } .b { background-color: yellow; margin-left:-10px; }
 <div class='a'> <div class='b'>Hello</div> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM