我的代码工作正常,并且显示了应用了很好的CSS的表格,但是当我缩小窗口表格时,不同的列占用了不同的空间,表格变得混乱(我已在屏幕截图中附加)。基本上,我希望没有复选框的第一列保持完整(粘性),其余列在缩小窗口时启用滚动,占用相同的空间。我该如何解决这个问题,有人可以帮忙吗?
有什么方法可以保持表格容器的宽度与桌面视图中的宽度相同,而只需在移动视图中放置滚动条并固定第一列而不缩小表格?
就像这个例子https://codepen.io/paulobrien/pen/LBrMxa
.hero-button {
padding: 27px;
cursor: pointer;
text-decoration: none !important;
}
a .hero-button1 {
min-height: 36px;
letter-spacing: normal;
border-width: 2px;
border-style: solid;
border-color: rgb(255, 255, 255);
border-image: initial;
border-radius: 25px;
padding: 6px 50px;
text-decoration: none;
display: inline-block;
font-size: 14px;
color: #fff;
font-weight: 600;
letter-spacing: 3px;
margin: 35px 0 0;
}
input {
color: black;
}
.table_container {
float: left;
width: 30rem;
margin-bottom: 3rem;
}
.table_container2 {
float: left;
width: 30rem;
margin-bottom: 3rem;
}
.container {
width: 100%; …Run Code Online (Sandbox Code Playgroud)我有一个div位于页面的大块上,这导致div下面的内容不再可选/可点击.
有办法解决这个问题吗?即:使div没有任何可点击的功能吗?
#page {
width: 980px;
padding: 0px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
position: relative;
}
#overlay {
margin: 0px;
padding: 0px;
height: 536px;
width: 422px;
position: absolute;
top: -4px;
right: -20px;
background-image: url(../images/overlay_full.png);
background-repeat: no-repeat;
background-position: left top;
}
Run Code Online (Sandbox Code Playgroud) 请考虑这个例子:( 工作示例)
样式声明:
body {background:#333;font:1em Arial, Helvetica, sans-serif;}
h1 {color:#ececec;text-align:center;margin:1.5em 0 1em;}
h2 {font-weight:normal;font-size:1.15em;
padding-bottom:5px;border-bottom:1px solid #999;}
p {padding-right:1em;color:#000;}
pre {font-size:1em;color:#06f;margin:1em 0;}
#wrapper {position:absolute;width:100px;height:100px;background:#ececec;
overflow:hidden;zoom:1;padding:20px;border-bottom:1px solid #000;
border-right:1px solid #000;border-top:1px solid #fff;
border-left:1px solid #fff;}
.css {float:right;width:50%;}
.markup {float:left;width:50%;margin-right:-1px;}
.box1,
.box2,
.box3,
.box4 {background:#fff;position:absolute;padding:10px;border:1px solid #333;}
.box1 {left:0;top:-20px;}
.box2 {right:0;top:0;}
.box3 {left:0;bottom:0;}
.box4 {right:-20px;bottom:-20px;}
Run Code Online (Sandbox Code Playgroud)
标记:
<body>
<h1>overflow:hidden and absolutely positioned elements</h1>
<div id="wrapper">
<div class="markup">
<div class="box1">box 1</div>
<div class="box2">box 2</div>
<div class="box3">box 3</div>
<div class="box4">box 4</div>
</div>
</body> …Run Code Online (Sandbox Code Playgroud) 我试图在屏幕的某个部分进行div填充,将412px留空到左侧和右侧.容易,嗯?
现在,当我添加position:absolute&top:0时,填充消失.元素检查器显示它是空的 - "填充"保持不变,但宽度:100%消失.我用过这段代码(没有定位):
<div style="height:73px; padding-left:413px; padding-right:413px;">
<div style="width:100%; height:73px; background:url(top-fill-small.png);">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
那么,我怎么能绝对定位它(我需要稍后动画),同时保留填充?我非常爱你的帮助.提前致谢!
我的问题很简单:绝对定位元素内的内联块元素会发生什么?我有一个例子来说明我的意思.否则很难解释.问题是为什么.icon内部的.tag位置不像前一个.icon(即内联和文本的右侧)
可以在http://jsbin.com/itole4/5上查看以下代码
<html>
<head>
<style>
.field { position: relative; border: 2px solid black;}
.tag { position: absolute; left: 100%; top: -2px; background: black; color: white;}
.icon { width:16px;height:16px; display: inline-block; background: gray; text-indent: -999px;}
</style>
</head>
<body>
<a>Some text <span class='icon'>X</span> </a>
<h2>
<span class='field'>Some Text<span class='tag'> tag<span class='icon'>x</span></span></span>
</h2>
<h2>
<span class='field'>Some Text</span>
</h2>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我的网页顶部有一个位置固定导航.导航还有一个下拉菜单,向下滑动并保持向下,直到再次单击它.
我想要实现的是,如果子菜单打开,并且用户决定稍微向下滚动页面,则子菜单将自动关闭.
我现在拥有的是:
$(document).scroll(function() {
$(".subMenu").slideUp(300);
});
Run Code Online (Sandbox Code Playgroud)
但是这种方法很敏感,并且用最轻微的滚动来关闭下拉.
理想情况下,我可以在我向上或向下滚动300px后重新启动菜单,以便有某种"缓冲"空间.
我想我的风格菜单栏像这样.当您向下滚动时,它固定在站点的顶部,并且在页面加载时它不固定.
如何用CSS完成?
我想用CSS在输入元素上显示span元素.我怎样才能做到这一点.我目前的代码:
<input type="url" placeholder="e.g. www.google.com" />
<span>http://</span>
Run Code Online (Sandbox Code Playgroud)
如何在输入元素上显示span元素,以便用户知道不需要输入http://所以如果已经有值,那么它就像输入中的span元素一样?我假设我可以用CSS定位来做到这一点.
我不能使用占位符,因为我不希望它被删除.
使用divhtml和css 创建全屏时,有两个主要选项:
使用方法: html, body, #myDiv {height: 100%, width: 100%}
要么: #myDiv{position: absolute; top:0px; bottom:0px; width: 100%}
一个相对于另一个有什么优势,或者它们可以互换使用吗?
我最近意识到position: staticIs是多么无用,除非relative同样如此,否则它不会为你提供任何东西.
事实上,我的问题是"为什么不将这一行添加到我们的CSS文件中呢?"
* { position:relative; }
Run Code Online (Sandbox Code Playgroud)
所以我们总是能够轻松地absolute从它的父元素中定位任何元素,或者移动元素它可以在left: ...任何方向上自相同或相同.
那么为什么元素relative默认不定位?
谢谢