×

background repeat round background

CSS 请教background-repeat: repeat-x 0 0?在css中background-attachment: fixed的意思是啥

admin admin 发表于2022-05-07 18:06:37 浏览131 评论0

抢沙发发表评论

CSS 请教background-repeat: repeat-x 0 0

首先,上面的写法“background-repeat: repeat-x 0 0”是无效的。 只有这样写“background: repeat-x 0 0”才是有效的。 意思就是背景以X轴(横向)平铺,并且起始平铺的位置是x坐标为0,y坐标为0,就是左上角横向平铺。 如果换成“background: repeat-x 0 -50px”的话就是Y坐标为负的50像素横向平铺。 需要注意的是除0之外所有的数值都要加上单位(比如像素px)。补充:针对gaosheng1984的回答,background-repeat: repeat-x 0 0;这样的写法是完全错误的!不要误导别人!不信你可以自己试一下,只有background-position才有 0 0这样的坐标控制,而background-repeatv根本没有!!写在一行只要用background: repeat-x 0 0就可以了!

在css中background-attachment: fixed的意思是啥

在CSS中,首先需要理解background-attachment的意思是定义背景图片随滚动轴的移动方式,取值方式有:scroll | fixed | inherit,scroll: 随着页面的滚动轴背景图片将移动,fixed: 随着页面的滚动轴背景图片不会移动,inherit: 继承,具体的用法通过代码来理解:《!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN“ “《html》《head》《meta 《title》CSS background-attachment 属性示例《/title》《style type=“text/css“ media=“all“》body {background-image:url(’/images/list-orange.png’); //图片的地址你可以去自行添加,这里只是假设的一种图片background-attachment:fixed;background-repeat:repeat-x; background-position:center center;position:absolute;height:5000px;}《/style》《/head》《body》《p》拖动滚动条,并且注意中间有一条橙色线并不会随滚动条的下移而上移.《/p》

在程序中用到了JLabel标签,但是我却没有办法改变它的背景色,我只知道label.setBackground(Color color)

JLabel label = new JLabel(); labe.setOpaque(true); label.setBackground(color);JLabel中默认标签是透明显示的,所以你不论怎么设置背景色都不会显示,你首先应该改变其透明度,上面labe.setOpaque(true); 是设置其为不透明,这样就可以了!!!