我的网站有多个菜单。我已经在带有类容器的 div 中定义了完整的页面内容,并应用了 bootstrap css 样式(margin-left:auto 和 margin-right:auto 等)以使页面居中。现在,其中一个文件中的元素必须从浏览器的最左侧开始。由于为父级应用了 css,我无法从左侧启动元素。我应用了带有负像素的 margin-left 来解决这个问题。但是当浏览器窗口很小时,元素在浏览器中并不完全可见,因为 margin-left 应用了负值。
<div class="container" style="margin-left:auto;margin-right:auto">
<div id="start_from_left" style="margin-left=-50px"> </div>
</div>
最佳答案
如果你的标签有
style=""
优先于其他任何事情。
您可以尝试在您的 css 标签上使用 !important,但这是不好的做法。
例如
margin-left:1px!important;
margin-right:0px!important;
关于css - 如何覆盖子元素的父元素CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33731708/