css里 Y轴的居中用什么 X轴的居中用什么

html-css012

css里 Y轴的居中用什么 X轴的居中用什么,第1张

background:.enter bottom no-repeat前面是url路径

全部的位置代码如下:

background-position: left 代表背景图横向(X轴)靠左,纵向(Y轴)居中。(9点钟位置)

background-position: right 代表背景图横向(X轴)靠右,纵向(Y轴)居中。(3点钟位置)

background-position: top 代表背景图横向(X轴)居中,纵向(Y轴)靠上。(12点钟位置)

background-position: bottom 代表背景图横向(X轴)居中,纵向(Y轴)靠下。(6点钟位置)

background-position: center 代表背景图横向(X轴)居中,纵向(Y轴)居中。(绝对居中)

background-position: left top 代表背景图横向(X轴)靠左,纵向(Y轴)靠上。(10点钟位置)

background-position: left bottom 代表背景图横向(X轴)靠左,纵向(Y轴)靠下。(7点钟位置)

background-position: right top 代表背景图横向(X轴)靠右,纵向(Y轴)靠上。(1点钟位置)

background-position: right bottom 代表背景图横向(X轴)靠右,纵向(Y轴)靠下。(5点钟位置)

CSS代码中如果要延x轴和y轴分别平铺背景代码,首先我们需要明确的是,你一般改的话,如果是在一个div中,是无法像你说的那样,只能实现的是平铺,repeat来实现的,如果是不同的2个div这样x和y是能能够实现的,通过repeat-x和repeat-y来实现,通过代码来理解:

<html>

<head>

<style>

#div1{

width:360px

height:400px

border:1px soild #f00

background:url('图片地址')repeat-x 0px 0px //沿x轴的

}

#div2{

width:360px

height:400px

border:1px soild #f00

background:url('图片地址')repeat-y 0px 0px //沿Y轴的

}

</style>

</head>

<body>

<div id='div1'></div>

<div id='div2'></div>

</body>

</html>