宽度:100%不带滚动条 [英] Width: 100% Without Scrollbars

查看:283
本文介绍了宽度:100%不带滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使网页的一部分适合浏览器的宽度,为此,我正在使用width: 100%,问题是它显示滚动条并且我不能使用overflow-x: hidden;,因为它会将某些内容隐藏起来,那么我该如何解决?

I'm trying to make a part of my webpage that fit the width of the browser, for this I'm using width: 100%, the problem is that it shows scrollbars and I can't use overflow-x: hidden; because it will make some of the content hidden, so how I can fix this?

#news {
    list-style-type: none;
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
    margin-right: 10px;
    margin-left: 10px;
    padding: 0;
    -webkit-user-select: text;
}

推荐答案

因为您使用的是position: absolute,而不是:

Because you're using position: absolute, instead of using:

width: 100%; margin-right: 10px; margin-left: 10px

您应该使用:

left: 10px; right: 10px

这将使您的元素占据可用的全部宽度,左右两侧留有10px空格.

That will make your element take the full width available, with 10px space on the left and right.

这篇关于宽度:100%不带滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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