html - 删除隐藏溢出的滚动条
问题描述
我试图隐藏溢出元素上的滚动条。
我尝试使用overflow: hidden;
但它不起作用。
这是我的最小示例:
#navbar {
width: 10000px;
border: solid red 1px;
overflow-x: hidden;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="container">
<div id="navbar">hello</div>
</div>
</body>
</html>
解决方案
是的,你可以拥有超过 100%,你可以将你的容器设置为 100%,并拥有你所需要的内部元素。
#container {
width: 100%;
overflow: hidden;
}
#navbar {
/* your requirement */
max-width: 10000px;
border: solid red 1px;
white-space: nowrap;
width: auto;
}
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="container">
<div id="navbar">Flex items have a default order value of 0, therefore items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful.
If you want to make one item display first, and leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid
out using Flexbox. By changing which item has the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have
a default order value of 0, therefore items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want
to make one item display first, and leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using
Flexbox. By changing which item has the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default
order value of 0, therefore items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make
one item display first, and leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox.
By changing which item has the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order
value of 0, therefore items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one
item display first, and leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By
changing which item has the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order value
of 0, therefore items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one item display
first, and leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By changing which
item has the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order value of 0, therefore
items with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one item display first, and
leave the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By changing which item has
the class active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order value of 0, therefore items
with an integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one item display first, and leave
the order of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By changing which item has the class
active assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order value of 0, therefore items with an
integer value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one item display first, and leave the order
of all other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By changing which item has the class active
assigned to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it. Flex items have a default order value of 0, therefore items with an integer
value greater than 0 will be displayed after any items that have not been given an explicit order value. You can also use negative values with order, which can be quite useful. If you want to make one item display first, and leave the order of all
other items unchanged, you can give that item an order of -1. As this is lower than 0 the item will always be displayed first. In the live code example below I have items laid out using Flexbox. By changing which item has the class active assigned
to it in the HTML, you can change which item displays first and therefore becomes full width at the top of the layout, with the other items displaying below it.</div>
</div>
</body>
</html>
推荐阅读
- javascript - 用于排除一些与起始字符串匹配的子文件夹的正则表达式
- html - 为什么我的页脚也有来自另一个容器的链接?
- c++ - 无法使用 INADDR_ANY 通过 WiFi 接收单播数据包
- javascript - jQuery层在底部附加标签而不是围绕它的项目
- python-3.x - 积分函数
- sql - 在没有窗口函数的情况下选择按结果分组的最小计数
- python - 在直方图上绘制来自 GMM 的估计高斯分量
- machine-learning - 梯度下降算法引发 valueError
- suitescript2.0 - 在 suitescript 2.0 中自动将行项目添加到供应商账单
- node.js - npm install http-server -g 不工作