我想将onsen ui页面的背景颜色设置为蓝色或某种颜色。我已尝试更新onsen-page中的样式,但似乎无效。
答案 0 :(得分:2)
你可以尝试
HTML 的
<ons-page class="red">
<h1>Page 1</h1>
</ons-page>
CSS
.red {
background-color: red;
}
答案 1 :(得分:0)
对于v2,让我引用在Gitter上提供此信息的@frandiox:
在
<div class="background"></div>
中提供v-ons-page
元素,并将其用作背景。您可以根据需要设置样式。更多信息:https://onsen.io/v2/guide/compilation.html#page-compilation
答案 2 :(得分:0)
试试这个,Javascript:
document.addEventListener("init",function(event){
if(event.target.id == "trn")
{
$("#trn .page__background").css("background","#ffffff");
}
});
温泉标签:
<ons-page id="trn">
</ons-page>
答案 3 :(得分:0)
关于malu ugo的上述回答的说明
页面上的页面将通过以下方式进行编译: 它会自动添加.page,div.page__background和div.page__content
<ons-page class="page">
<ons-toolbar></ons-toolbar>
<div class="page__background"></div>
<div class="page__content">
Some content here
<ons-input></ons-input>
<div>More content</div>
</div>
<ons-fab></ons-fab>
</ons-page>
使用javascript更改背景
Javascript:
document.addEventListener("init",function(event){
if(event.target.id == "trn")
{
$("#trn .page__background").css("background","#ffffff");
}
});
温泉标签:
<ons-page id="trn">
</ons-page>
答案 4 :(得分:0)
<ons-template id="tab1.html">
<ons-page id="first-page" >
<div class="background"></div>
<p style="text-align: center;">
My Text
</p>
<style>
.background{
background-color: black;
}
</style>
</ons-page>
</ons-template>
添加班级背景的div应该有助于设置背景样式