css div滚动

Introduction:

介绍:

Dealing with divs has become a regularity and divs are used for many purposes like to structure our code and to segregate our various sections of codes. Besides, we are also aware of many properties that we can imply or amend over divs to make our website or web page responsive but there are times we tend to forget some of the methods or properties which could be used while developing a website or web page and sometimes these properties also make our work easy, as sometimes they happen to reduce the number of codes. So one must always keep learning about various properties to explore new ways for developing a website or web page. With that note in mind, we must move forward with our topic.

处理div已经成为一种常态,并且div用于许多目的,例如构造我们的代码和分离我们的代码的各个部分。 此外,我们也意识到我们可以暗示或修改div以使我们的网站或网页具有响应性的许多属性,但有时我们会忘记开发网站或网页时可以使用的某些方法或属性有时这些属性也使我们的工作变得容易,因为有时它们恰好减少了代码数量。 因此,必须始终了解各种属性,以探索开发网站或网页的新方法。 牢记这一点,我们必须推进我们的主题。

The task:

任务:

To create a vertically scrollable div is not a challenging task as it seems but as mentioned earlier, one must keep learning new methods or properties, besides there might come a time when you will require a vertically scrollable div and at that time you would know the exact answer to your problem, all thanks to this article. Well, now that we have established an understanding of the importance of this discussion, so without much further adieu, let us move on with the task.

创建一个垂直可滚动的div看起来并不是一项艰巨的任务,但是正如前面提到的,人们必须不断学习新的方法或属性,此外,有时候可能需要垂直可滚动的div,那时您会知道对您问题的确切答案,这一切都归功于本文。 好了,既然我们已经对这次讨论的重要性有了一个了解,那么就不用多说了,让我们继续进行下去。

Property used:

使用的属性:

As mentioned earlier, creating a vertically scrollable div is not tough, some things here and there and you will catch up to it in no time. For creating a vertically scrollable div for your website or web page you have to make use of a property known as overflow property. You might as well be familiar with this property and its behavior. So, by using overflow one can create a vertically scrollable div. As we all know that Overflow property takes up a certain amount of values such as overflow-x: hidden and overflow-y: auto. By making use of these values you will be able to create vertical and horizontal scroll bars.

如前所述,创建一个垂直可滚动的div并不困难,到处都是,您很快就会赶上它。 为了为您的网站或网页创建一个垂直滚动的div,您必须使用一个被称为溢出属性的属性 。 您可能还熟悉此属性及其行为。 因此,通过使用溢出可以创建一个垂直滚动的div。 众所周知,Overflow属性会占用一定数量的值,例如overflow-x:hidden和overflow-y:auto。 通过使用这些值,您将能够创建垂直和水平滚动条。

Solution:

解:

To create a vertical scroll bar use x and y-axis and you should set the overflow-x property as hidden and overflow-y property as auto. By doing so the horizontal scroll bar property would hide automatically and only vertical scroll bar would be displayed. Therefore, the scroll bar created in the process would be vertically.

创建垂直滚动条,请使用x和y轴,您应将overflow-x属性设置为hidden ,将overflow-y属性设置为auto 。 这样,水平滚动条属性将自动隐藏,并且仅显示垂直滚动条。 因此,在该过程中创建的滚动条将是垂直的。

Syntax:

句法:

    Element{
overflow-x:hidden;
overflow-y:auto;
}

Example:

例:

<!DOCTYPE html>
<html>
<head>
<style>
div {background-color: #006969;
color: #fff;
width: 400px;
height: 100px;
overflow-x: hidden;
overflow-y: auto;
text-align: justify;
}
</style>
</head>
<body>
<h1>create a vertically scrollable div</h1>
<div>
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
This is IncludeHelp. This is IncludeHelp. This is IncludeHelp.
</div>
</body>
</html>

In the above example, the div is vertically scrollable.

在上面的示例中, div可垂直滚动

Try yourself:

尝试一下:

Pretty easy right? All we had to do was make use of a very familiar property known as Overflow property and set its x-axis value to hidden and y-axis value auto and bam! A vertical scrollable div emerged as a result. So go ahead and try this new learned method on your own by taking the help of examples. And if you think you need some assistance our writers and experts are available for you at https://ask.includehelp.com/.

很容易吧? 我们要做的就是利用一个非常熟悉的属性,即Ove​​rflow属性,并将其x轴值设置为hidden和y轴值auto和bam! 结果出现了一个垂直的可滚动div。 因此,请继续通过示例来尝试这种新学到的方法。 如果您认为需要帮助,请访问https://ask.includehelp.com/,我们的作家和专家将为您提供帮助。

翻译自: https://www.includehelp.com/code-snippets/how-to-create-a-vertically-scrollable-div.aspx

css div滚动

css div滚动_如何使用CSS创建可垂直滚动的div?相关推荐

  1. css如何让滚轮滚动时 不让页面滚动_中国第五届 CSS 大会参会总结

    编者按:本文作者:安佳,360 搜索事业部的前端开发工程师,W3C CSS 工作组成员. 本次大会共有 7 个主题: 新时代 CSS 布局.陈慧晶 剖析 css-tricks 新版,为你所用.大漠 C ...

  2. css 动画使用_如何在CSS中使用动画

    css 动画使用 使用CSS动画 (Using CSS Animations) CSS animations add beauty to the webpages and make transitio ...

  3. msclass 文字滚动_【JS特效】不间断滚动效果通用类

    网上发现一个不错的js不间断滚动效果,今天来转载一下吧.这个js的作者应是崔永祥(因其博客已不存在,而无法确认),我这里只简单整理,只为笔记. ??? 需要通过样式,js来实现这个翻滚效果. ??? ...

  4. vue css 应用变量_如何使用CSS Grid和CSS变量快速为应用创建原型

    vue css 应用变量 CSS Grid and CSS Variables are both huge wins for front-end developers. The former make ...

  5. 引用自己创建的css样式表_如何使用CSS创建联系表

    引用自己创建的css样式表 First we create the HTML elements - input fields for First Name, Last Name, Email and ...

  6. css grid布局_如何使用CSS Grid重新创建Medium的文章布局

    css grid布局 When people think of CSS Grid they normally envision image grid layouts and full web page ...

  7. css画布背景_如何使用CSS和触摸JavaScript构建画布外菜单

    css画布背景 在本教程中,我们将介绍一种简单而有效的方法,以使用HTML,CSS和JavaScript创建画布菜单. 要初步了解我们将要构建的内容,请查看相关的CodePen演示(请查看较大的版本以 ...

  8. css 网格布局_我从CSS网格布局中学到的东西

    css 网格布局 by Jennifer Wjertzoch 珍妮弗·维佐奇 我从CSS网格布局中学到的东西 (Things I've learned about CSS grid layout) W ...

  9. css 字体大小_用一个 CSS 属性打造自适应网站

    英文 | https://dev.to/dip15739/responsive-website-with-only-1-css-property-3ea9 作者 | Dip Vachhani 用一个c ...

最新文章

  1. mysql超大数据库备份
  2. Madgwick算法详细解读
  3. Docker镜像的目录存储讲解
  4. PHPCMS资源网站源码软件源码下载站网站源码
  5. HBuilder打包App方法
  6. 【Spring】一次线上@Transational事务注解未生效的原因探究
  7. iPhone 12 5G更耗电?续航时间较4G妥妥地缩短不少
  8. 基于STM32的步进电机驱动设计
  9. 小学教育专业语文方向毕业论文怎么选题?
  10. hadoopsnappy解压_Hadoop安装配置snappy压缩
  11. qt4.8.5在arm下的移植
  12. 2019年安徽大学ACM/ICPC实验室新生赛
  13. 【转】从“致加西亚的信”看自行管理
  14. 电子签名合同的有效期是多久
  15. 基于52840 S340协议栈USB flash U盘实现
  16. 股票集合竞价规则详解,什么是集合竞价?集合竞价技巧分析
  17. 【数字图像处理】实验一 图像的平移,缩放和旋转(vs2017+opencv)
  18. uniApp学习(8)搜索框的创建和自动获取焦点
  19. WinCC 7.0 用户归档+Listview控件 制作报表(一)
  20. 有关剑侠情缘网络版开发的一篇文章

热门文章

  1. v7000更换电池步骤_ups电源运行中是否可以更换电池?应如何操作呢
  2. gcc参数 -i, -L, -l, -include
  3. linux shell结构,linux——Shell的控制结构(附shell编写代码和运行结果)
  4. python程序打包成安卓app教程_Python打包方法基本应用方式介绍
  5. 云服务器php版本修改,云服务器 更改php版本
  6. easyui java管理系统_EasyUI 后台管理系统
  7. Linux 服务器拷贝远程文件 SCP
  8. ubuntu7.10下的vi用的怪怪的
  9. [HNOI2009]有趣的数列
  10. HTTP1.1新增了五种请求方法:OPTIONS、PUT、PATCH、DELETE、TRACE 、 CONNECT