CSS隐藏滚动条(如果不需要) [英] CSS hide scroll bar if not needed

查看:179
本文介绍了CSS隐藏滚动条(如果不需要)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何隐藏 overflow-y:scroll; 如果不需要。我的意思是,我正在建立一个网站,我有一个主要区域的帖子将显示,如果内容不超过当前的宽度,我想隐藏滚动条。

I am trying to figure out how I can hide the overflow-y:scroll; if not needed. What I mean is that I am building a website and I have a main area which posts will be displayed and I want to hide the scroll bar if content does not exceed the current width.

另外,我的第二个问题。我想让它当帖子超过当前的宽度,宽度会自动增加,内容将不会开箱。

Also, my second question. I want to make it so when the posts exceed the current width, the width will increase automatically and the content won't go out of the box.

有人有一个如何做到这一点?

Does anyone have a clue how to do this?

帖子区域:

.content {
    height: 600px;
    border-left: 1px solid;
    border-right: 1px solid;
    border-bottom: 1px solid;
    font-size: 15px;
    text-align: justify;
    line-height: 19px;
    overflow-y:scroll;
}

主网站容器:

.container {
    margin: 0 auto;
    width: 757px;
    margin-top: 30px;
    text-align: center;
}


推荐答案

设置 overflow-y 属性到 auto ,或者如果没有继承则删除该属性。

Set overflow-y property to auto, or remove the property altogether if it is not inherited.

这里是解决的两个问题的工作示例。

Here is a working example of both the problems solved.

这篇关于CSS隐藏滚动条(如果不需要)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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