页面整体向左移几个像素,css怎么写

html-css010

页面整体向左移几个像素,css怎么写,第1张

首先在CSS里定义间距主要有四个关键字,margin border padding content 边界距,边框,填充,内容。如果是定义靠近左的距离,那就加个margin-left: ?px ?是定义多少像素,根据需要填写,写完之后保存,那条Css所控制的div或table等标签就会发生改变,同理,margin-right margin-top magin-bottom 都一样。网络这门艺术是要自己多推敲的多操练的,我高中毕业,没有接受过任何该知识的教育,但现在同样在公司里是技术骨干,也算是翘楚一枝。学习这档事是自己的事,问题应该尽量自己多思考,而不应该随便这么一问,就解决了。呵呵,废话多了,我是过来人嘛 都是用手机打的 很辛苦哦 有不明白的地方再沟通 随时关注

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<style type="text/css">

* {

margin: 0

padding: 0

}

.demo {

margin: 0 0 0 100px

}

.img {

width: 200px

height: 200px

border: 1px solid #DCDCDC

padding: 5px

box-sizing: border-box

}

.img img {

width: 100%

height: 100%

}

.msg {

width: 200px

text-align: center

box-sizing: border-box

word-break: keep-all

white-space: nowrap

overflow: hidden

text-overflow: ellipsis

position: relative

border: 1px solid #000000

/*left: -30px你是不是布局出现了问题,如果你非要左移的话,去掉注释*/

}

</style>

<body>

<div class="demo">

<div class="img">

<img src="http://pic1.win4000.com/wallpaper/6/578855acae491.jpg" />

</div>

<div class="msg">

自驾游(多余的文字)<br> 会员价:

<strong style="color: red">9999元</strong>

</div>

</div>

</body>

</html>

background-position: top left 可以用负值

您需要把 background-attachment 属性设置为 "fixed",才能保证该属性在 Firefox 和 Opera 中正常工作