亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

CSS の配置

CSS 配置


CSS 配置プロパティを使用すると、要素を配置できます。また、ある要素を別の要素の後ろに配置し、ある要素のコンテンツが大きすぎる場(chǎng)合に何が起こるかを指定することもできます。

要素は、top、bottom、left、right 屬性を使用して配置できます。ただし、これらのプロパティは、position プロパティが最初に設(shè)定されない限り機(jī)能しません。位置決め方法に応じて、動(dòng)作方法も異なります


4 つの異なる位置決め方法があります。

靜的配置

HTML 要素のデフォルト値。つまり、配置なしで要素は通常のフローに表示されます。

靜的に配置された要素は、上下左右の影響を受けません。


固定位置

要素の位置はブラウザウィンドウに対して固定されます。

ウィンドウがスクロールされても動(dòng)きません:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
p.pos_fixed
{
	position:fixed;
	top:30px;
	right:5px;
}
</style>
</head>
<body>

<p class="pos_fixed">Some more text</p>
<p><b>注意:</b> IE7和IE8支持只有一個(gè)!DOCTYPE指定固定值.</p>
<p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p><p>Some text</p>
</body>
</html>

プログラムを?qū)g行して試してください


相対位置決め

相対的に配置された要素は、通常の位置に対して相対的に配置されます。

 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
h2.pos_left
{
	position:relative;
	left:-20px;
}

h2.pos_right
{
	position:relative;
	left:20px;
}
</style>
</head>

<body>
<h2>This is a heading with no position</h2>
<h2 class="pos_left">This heading is moved left according to its normal position</h2>
<h2 class="pos_right">This heading is moved right according to its normal position</h2>
<p>Relative positioning moves an element RELATIVE to its original position.</p>
<p>The style "left:-20px" subtracts 20 pixels from the element's original left position.</p>
<p>The style "left:20px" adds 20 pixels to the element's original left position.</p>
</body>

</html>

プログラムを?qū)g行して試してみてください

相対的に配置された要素や互いに重なっている要素の內(nèi)容は移動(dòng)できますが、元の占有スペースは変わりません。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
h2.pos_top
{
	position:relative;
	top:-50px;
}
</style>
</head>

<body>
<h2>This is a heading with no position</h2>
<h2 class="pos_top">This heading is moved upwards according to its normal position</h2>
<p><b>注意:</b> 即使相對(duì)定位元素的內(nèi)容是移動(dòng),預(yù)留空間的元素仍保存在正常流動(dòng)。</p>
</body>

</html>

相対的に配置された要素は、絶対的に配置された要素のコンテナ ブロックとしてよく使用されます。


絶対配置

絶対配置された要素の位置は、最も近くに配置された親要素を基準(zhǔn)とします。要素に配置された親要素がない場(chǎng)合、その位置は次のようになります。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
h2
{
	position:absolute;
	left:100px;
	top:150px;
}
</style>
</head>

<body>
<h2>This is a heading with an absolute position</h2>
<p>用絕對(duì)定位,一個(gè)元素可以放在頁(yè)面上的任何位置。標(biāo)題下面放置距離左邊的頁(yè)面100 px和距離頁(yè)面的頂部150 px的元素。.</p>
</body>

</html>

プログラムを?qū)g行してください。試してみてください

絶対配置では、要素の位置がドキュメント フローから獨(dú)立するため、スペースを占有しません。

絶対的に配置された要素は他の要素と重複します。


要素の重なり

要素はドキュメントフローとは獨(dú)立して配置されるため、ページ上の他の要素と重なることができます

z-index 屬性は、要素の積み重ね順序 (どの要素が最初に來(lái)るか、または後ろ)

要素には正または負(fù)の重なり順を指定できます:

     <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文網(wǎng)(php.cn)</title>
    <style>
        img
        {
            position:absolute;
            left:0px;
            top:0px;
            z-index:-1;
        }
    </style>
</head>

<body>
<h1>This is a heading</h1>
<img src="https://img.php.cn/upload/course/000/000/006/5809800b44336872.jpg" width="100" height="140" />
<p>因?yàn)閳D像元素設(shè)置了 z-index 屬性值為 -1, 所以它會(huì)顯示在文字之后。</p>
</body>
</html>

プログラムを?qū)g行して試してみてください


重なり順が高い要素は常に、重なり順が低い要素の前にあります。

: 配置された 2 つの要素が重なっていて、z-index が指定されていない場(chǎng)合、HTML コード內(nèi)で最後に配置された要素が一番上に表示されます。


その他の例

スクロールバーを使用して要素內(nèi)のオーバーフローコンテンツを表示する方法

      <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
<style>
div.scroll
{
	background-color:#00FFFF;
	width:100px;
	height:100px;
	overflow:scroll;
}

div.hidden 
{
	background-color:#00FF00;
	width:100px;
	height:100px;
	overflow:hidden;
}
</style>
</head>

<body>
<p>overflow 屬性規(guī)定當(dāng)內(nèi)容溢出元素框時(shí)發(fā)生的事情。.</p>

<p>overflow:scroll</p>
<div class="scroll">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>

<p>overflow:hidden</p>
<div class="hidden">You can use the overflow property when you want to have better control of the layout. The default value is visible.</div>
</body>
</html>

プログラムを?qū)g行して試してみる


カーソルを変更する方法

 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title> 
</head>
<body>
<p>將鼠標(biāo)移動(dòng)到這些字上改變鼠標(biāo)樣式cursor.</p>
<span style="cursor:auto">auto</span><br>
<span style="cursor:crosshair">crosshair</span><br>
<span style="cursor:default">default</span><br>
<span style="cursor:e-resize">e-resize</span><br>
<span style="cursor:help">help</span><br>
<span style="cursor:move">move</span><br>
<span style="cursor:n-resize">n-resize</span><br>
<span style="cursor:ne-resize">ne-resize</span><br>
<span style="cursor:nw-resize">nw-resize</span><br>
<span style="cursor:pointer">pointer</span><br>
<span style="cursor:progress">progress</span><br>
<span style="cursor:s-resize">s-resize</span><br>
<span style="cursor:se-resize">se-resize</span><br>
<span style="cursor:sw-resize">sw-resize</span><br>
<span style="cursor:text">text</span><br>
<span style="cursor:w-resize">w-resize</span><br>
<span style="cursor:wait">wait</span><br>
</body>
</html>

走るそれを試してみるプログラム




學(xué)び続ける
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <style> img { position:absolute; left:0px; top:0px; z-index:-1; } </style> </head> <body> <h1>This is a heading</h1> <img src="https://img.php.cn/upload/course/000/000/006/5809800b44336872.jpg" width="100" height="140" /> <p>因?yàn)閳D像元素設(shè)置了 z-index 屬性值為 -1, 所以它會(huì)顯示在文字之后。</p> </body> </html>
提出するリセットコード