Javascript 位置:固定引线,无背景色
我将样式Javascript 位置:固定引线,无背景色,javascript,html,css,position,Javascript,Html,Css,Position,我将样式位置:fixed添加到#wrapper div元素中,然后背景色:#333不显示 这是我的密码: winWidth=window.innerWidth | | document.body.clientWidth; headMarg=(winWidth-636)/2; document.getElementById(“header”).style.transform=“translate”(“+headMarg+”px,10px)”; document.getElementById(“包
位置:fixed
添加到#wrapper div
元素中,然后背景色:#333
不显示
这是我的密码:
winWidth=window.innerWidth | | document.body.clientWidth;
headMarg=(winWidth-636)/2;
document.getElementById(“header”).style.transform=“translate”(“+headMarg+”px,10px)”;
document.getElementById(“包装器”).style.width=winWidth;
document.getElementById(“包装器”).style.position=“固定”;
document.getElementById(“content”).style.width=winWidth*2/3+“px”代码>
@导入url('https://fonts.googleapis.com/css?family=VT323');
身体{
字体系列:VT323;
字体大小:20px;
背景色:#EFEF;
}
#标题{
背景色:rgba(255、255、255、0.6);
高度:70像素;
位置:固定;
}
.标签{
左边框:2px实心#F1453D;
右边框:2px实心#F1453D;
左侧填充:30px;
右侧填充:30px;
过渡:均为0.3秒;
}
.选项卡:悬停{
背景色:#F1453D;
颜色:白色;
}
#包装纸{
背景色:#333;
高度:90px;
盒影:0px 5px 5px灰色;
}
#内容{
背景色:白色;
高度:1000px;
}
按钮
家
玩吧!
关于
帐户
hi和测试
位置:固定的
从流中删除元素,因此它不知道它有多长(它没有宽度
)。所以你需要告诉元素它应该伸展多远
#wrapper{
background-color:#333;
height:90px;
width:100%; // <--- add this
box-shadow:0px 5px 5px grey;
}
#包装器{
背景色:#333;
高度:90px;
宽度:100%;//未设置宽度,添加宽度:100%我在结尾使用DOM将宽度设置为屏幕的大小缺少+“px”,然后我确实使用DOM javascriptYes设置了宽度。是的,无论您如何应用样式:样式表、内联或javascript,最终结果都是一样的。我修复了它,因为我忘记添加“px”在firstAh gotcha的结尾,我没有注意到这一点。正因为如此,最好使用样式表进行样式设计:)