使div忽略父div,将margin设置为0 auto [英] Make div ignore parent div which has margin set to 0 auto

查看:106
本文介绍了使div忽略父div,将margin设置为0 auto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何忽略父div的样式

How can I ignore the style of the parent div

margin: 0 auto;

我想忽略一个div的样式而不嵌套它的父类。这是可能在CSS?

I want to ignore this style for a div without nesting it outside of its parent. Is this possible in CSS?

推荐答案

只要设置孩子的边距。这将覆盖父的CSS。 CSS以层次化的方式工作,其中使用最具体的CSS(最接近元素,缺少更好的术语)。

Just set the child's margins. That will override the parent's css. CSS works in a hierarchical fashion where the most specific CSS is used ("closest" to the element for lack of a better term).

这篇关于使div忽略父div,将margin设置为0 auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆