<html>
<head>
</head>
<body background="D:\Desert.jpg">
HI..This IS DESERT image.
</body>
</html>
當我運行此代碼圖像是Repeat.I想在screen.Without全尺寸圖像。 我想要這個HTML。如何設置高度和在html中的背景圖像
<html>
<head>
</head>
<body background="D:\Desert.jpg">
HI..This IS DESERT image.
</body>
</html>
當我運行此代碼圖像是Repeat.I想在screen.Without全尺寸圖像。 我想要這個HTML。如何設置高度和在html中的背景圖像
可以在body標籤給像
<body style="background-repeat: no-repeat; background-size: cover; background-image: url("D:\Desert.jpg");height:500px;width:100%;">
<div style="background-image: url(https://cdn.pixabay.com/photo/2016/03/21/10/44/desert-1270345_960_720.jpg);background-position: center;background-repeat: no-repeat;background-size: contain;height: 500px;width: 500px;">
您可以通過在HTML標籤中加入一種風格給在HTML代碼本身的CSS屬性。
asumming that you have a 500px height and div div 這裏:背景位置:中心(意味着圖像將居中)
background-size:包含(意味着圖像將被包含在div內,你可以改變覆蓋它顯示爲封面圖片)
這裏是Fiddle
.image{
background:url('https://beebom-redkapmedia.netdna-ssl.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg');
height:500px;
color:white;
}
<div class='image'>
HI..This IS DESERT image.
</div>
我想補充一個「背景重複:沒有repea噸;」停止重複圖像。
.image{
background:url('https://beebom-redkapmedia.netdna-ssl.com/wp-content/uploads/2016/01/Reverse-Image-Search-Engines-Apps-And-Its-Uses-2016.jpg');
height:500px;
width:100%
color:white;
background-repeat: no-repeat;
}
<div class='image'>
HI..This IS DESERT image.
</div>
你必須使用CSS that.If你真的需要純HTML使用一個大的圖像
<body style = "background-repeat: no-repeat; background-size: cover; background-image: url("D:\Desert.jpg");height:500px;width:100%;">
安基塔帕特爾提到它上面