简体   繁体   English

为什么使用顶部或底部会降低元素的高度?

[英]Why Does Using top or bottom Reduce the Element's Height?

I'm trying to position an icon responsively which is part of a plugin in WordPress.我正在尝试以响应方式定位一个图标,它是 WordPress 插件的一部分。

Using margin-top and margin-bottom works to position the icon further down the page, but top and bottom above 10px seems to reduce the height of the icon when used in conjunction with position: relative;使用margin-topmargin-bottom可以将图标放置在页面bottom ,但是topbottom高于10px似乎与position: relative;结合使用时降低了图标的高度position: relative;

@media(max-width: 768px) {
    #a2a_share_save_widget-3 {
        position: relative !important;
        top: 20px !important;
        left: 95%;
        margin-left: -37px;
        background-color: transparent! important;
        color: transparent! important;
    }
}

If I reduce top to 10px , the icon goes back to full height again.如果我将top减少到10px ,图标会再次恢复到全高。

Html:网址:

<div id="a2a_share_save_widget- 3" class="widget widget_a2a_share_save_widget">
    <div class="a2a_kit a2a_kit_size_32 addtoany_list">
        <a class="a2a_dd a2a_counter addtoany_share_save addtoany_share" href="https://www.addtoany.com/share"></a>.
    </div>
</div>

What I want is to apply top or bottom to adjust position, not icon height.我想要的是应用topbottom来调整位置,而不是图标高度。

Mobile page here移动页面在这里

The issue is not with regards to the share widget's height being reduced.问题不在于共享小部件的高度被降低。 The issue is that overflow: hidden is given to its ancestor section - the share widget is technically overflowing and parts of it are hidden.问题是overflow: hidden被赋予其祖先section - 共享小部件在技术上是溢出的并且它的一部分被隐藏。

So to solve this, either remove/override the property overflow: hidden from section因此,要解决此问题,请删除/覆盖属性overflow: hidden from section

#content section {
    overflow: visible;
}

or have the widget's container take X amount of minimum height或者让小部件的容器取 X 量的最小高度

div#main {
    min-height: 80px;
}

I imagine you want to increase specificity as these examples are generic terms and you are using a wordpress theme我想您想提高特异性,因为这些示例是通用术语,并且您使用的是 wordpress 主题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从下到上为元素的最大高度设置动画? - How to animate an element's max-height from bottom to top? 限制元素的高度但显示底部而不是顶部 - Restrict an element's height but show the bottom part instead of the top top/bottom:[%] 基于父元素的边框而不是高度 - top/bottom:[%] based on parent element's borders instead of height 为什么元素的负底部边距会降低该元素的父级高度? - Why does a negative bottom margin on an element decrease the height of parent of that element? 降低div顶部和底部的高度(不仅仅是底部) - Reduce height from top and bottom of div (not just bottom) 为什么人体内部顶层元素的边距会改变人体的高度? - Why does the margin of a top-level element inside the body change the body's height? jQuery高度动画在顶部,而不是元素的底部 - jQuery height animation at the top, not the bottom of an element 为什么 <img> 当使用左/右/上/下与宽度/高度相比时,不会拉伸 - Why <img>'s are not stretched when sized with left / right / top / bottom vs width / height 粘性元素在元素底部使用顶部? - Sticky element on bottom of element using top? 为什么display:table将父元素的高度设置为其最大的浮动子元素的高度? - Why does display:table set the parent element's height to its biggest floating child element's height?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM