」。"/> 」。">

首頁  >  文章  >  web前端  >  html怎麼設定div橫向捲軸不顯示

html怎麼設定div橫向捲軸不顯示

WBOY
WBOY原創
2022-01-18 14:50:444320瀏覽

在html中,可以利用style和「overflow-x」屬性設定div橫向移動捲軸不顯示,當屬性的值設定為「hidden」時,就會不提供橫向捲動機制,語法為“

”。

html怎麼設定div橫向捲軸不顯示

本教學操作環境:windows10系統、HTML5版、Dell G3電腦。

html怎麼設定div橫向捲軸不顯示

overflow-x屬性指定如果它溢出了元素的內容區是否剪輯左/右邊緣內容。

語法為:

overflow-x: visible|hidden|scroll|auto|no-display|no-content;

其中參數表示如下:

html怎麼設定div橫向捲軸不顯示

#範例如下:

<html>
<head>
<meta charset="utf-8"> 
<title>123</title> 
<style> 
div
{
width:110px;
height:110px;
border:thin solid black;
overflow-y:hidden;
}
</style>
</head>
<body>
<div style="overflow-x:hidden;"><p style="width:140px">
In my younger and more vulnerable years my father gave me some advice that I&#39;ve been turning over in my mind ever since.
&#39;Whenever you feel like criticizing anyone,&#39; he told me, &#39;just remember that all the people in this world haven&#39;t had the advantages that you&#39;ve had.&#39; 
</p></div>
<p>Overflow-x指定是否要剪辑的左/右边缘的内容.</p>
<p>Overflow-y指定是否要剪辑的顶部/底部边缘的内容</p>
</body>
</html>

當沒有為div元素添加style="overflow-x:hidden;"樣式時,輸出結果如下:

html怎麼設定div橫向捲軸不顯示

#上述範例新增了該樣式,輸出結果如下:

html怎麼設定div橫向捲軸不顯示

推薦教學:《html影片教學

以上是html怎麼設定div橫向捲軸不顯示的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn