背景图片叠加太大

时间:2017-01-28 20:25:23

标签: android html css

我有以下css来显示背景图像

height: 90%; /* or whatever, equal to the image you want 'watermarked' */
    width: 90%; /* as above */
    background-image: url('<?php echo "study/".$_SESSION['bkground_img']; ?>');
    background-repeat: no-repeat;
    position: absolute;
    opacity: 1; /* Firefox, Chrome, Safari, Opera, IE >= 9 (preview) */
    filter:alpha(opacity=50); /* for <= IE 8 */
    background-size: cover;
     -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;

我遇到的问题是背景图像太大而且不适合屏幕。我希望它随着屏幕大小而改变,甚至是手机

2 个答案:

答案 0 :(得分:0)

添加此css可能有效

public class TestPaneController implements Initializable {

    @FXML private Pane testPane ;
    @FXML private Button button;
    @FXML private Label labelName;


    private ViewState viewState ;

    public void setViewState(ViewState viewState) {
        this.viewState = viewState ;
    }

    public void initialize(URL arg0, ResourceBundle arg1) {
        button.setOnAction(event->
            viewState.setCurrentView(testPane));
    }
}

答案 1 :(得分:0)

也许一些图片编辑可以帮到你。此外,如果您的图像可用,请尝试在x或y坐标上复制图像使用此代码:

body{ background-image:url(background.jpg); background-repeat: repeat-y; /* or repeat-x, it is based on how you want */ }

我希望这个答案对你有用:)