- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的绝对定位元素设置为 100% 的宽度,但即便如此,当它呈现时它会创建一个水平滚动条并超出页面边界。在浏览器中查看时,上面的静态定位元素看起来更短,即使它们也跨越了整个宽度。
这是正在呈现的代码:有问题的元素是#navlinks https://gist.github.com/anonymous/5d8bde1f196b919dab297560ff85b072
@charset "utf-8";
#wrapper {}
h1,
h2 {
color: #1E1E1E;
font-style: normal;
font-weight: 400;
}
h1 {
margin-top: 0px;
margin-bottom: 0px;
padding-top: 0px;
padding-bottom: 20px;
}
#wrapper #hero {
max-height: 400px;
overflow: hidden;
}
#menulink {
margin: 0;
text-align: center;
background-color: #1E1E1E;
}
#menulink a {
text-transform: uppercase;
color: white;
font-weight: 200;
text-decoration: none;
display: block;
padding-top: 0.1em;
padding-bottom: 0.1em;
}
#navlinks {
position: absolute;
width: 100%;
margin: 0;
padding: 0;
text-align: center;
background-color: rgba(0, 0, 0, 0.53);
}
#navlinks a {
display: block;
padding-top: 10px;
padding-bottom: 10px;
font-weight: 400;
text-decoration: none;
text-transform: uppercase;
}
#wrapper #hero img {
max-width: 100%;
}
figure {
width: 400px;
margin-left: auto;
margin-right: auto;
}
figure img {
max-width: 100%;
}
.grayscale {
filter: grayscale(100%);
}
.grayscale:hover {
filter: grayscale(0%);
}
<div id="wrapper">
<header>
<h1> Bayside Beat</h1>
<nav>
<h2 id="menulink"><a href="#navlinks">Menu</a></h2>
<ul id="navlinks">
<li> <a href="#"> Home </a></li>
<li> <a href="#">Sights </a></li>
<li> <a href="#">Dining </a></li>
<li> <a href="#">Events </a></li>
<li> <a href="#">Lodging </a></li>
</ul>
</nav>
</header>
<div id="hero">
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg">
<p>Bayside Beat keeps you informed of the best places to see, eat, and sleep in the City by the Bay.</p>
</div>
<main>
<h2>Riding the Cable Cars</h2>
<p> No visit to San Francisco is complete without a ride on the iconic cable cars that climb up the vertiginous hills of the city. Of the twenty-three lines established between 1873 and 1890, three remain: two routes from downtown near Union Square to
Fisherman's Wharf, and a third route along California Street.</p>
<p>The cable cars rely on cables running constantly beneath the road’s surface. The driver—or gripman—uses a lever to grip the cable to pull the car and its passengers up the hill. The gripman requires not only great strength, but also great skill. He
needs to know where to release the cable to coast over crossing cables and points. The conductor works in close cooperation with the gripman, operating the brake at the rear of the car to prevent it from running out of control on the downward slopes.</p>
<figure> <img src="http://www.hdwallpapers.in/walls/lotus_flowers-wide.jpg" class="grayscale">
<figcaption>The cable car terminus near Union Square.
</figcaption>
</figure>
<p>Although the cable cars are now mainly a tourist attraction, they’re still used by local commuters to get to and from work. The California Street line is particularly popular among commuters on weekdays. </p>
</main>
<aside>
<h2>Cable Car Tips</h2>
<p>A single ride on a cable car costs $7. If you plan to travel around the city, it’s often cheaper to buy a Muni Passport, which gives you unlimited rides on San Francisco’s extensive public transport system, including the cable cars (but not the BART
subway system). Even a single-day passport ($20) will save you money if you make a return trip, and stop off to visit Chinatown one way.</p>
<p>There are often long lines at the cable car terminus, particularly on the Powell-Mason and Powell-Hyde routes. If you don’t want to wait, try walking a few stops along the route. The conductor usually leaves a small number of places to pick up passengers
on the way. The California Street route is generally less crowded (but not as spectacular).</p>
</aside>
<footer>
<p>© Copyright 2013–16 Bayside Beat</p>
</footer>
</div>
最佳答案
添加position:relative于导航。
@charset "utf-8";
#wrapper {}
h1,
h2 {
color: #1E1E1E;
font-style: normal;
font-weight: 400;
}
h1 {
margin-top: 0px;
margin-bottom: 0px;
padding-top: 0px;
padding-bottom: 20px;
}
#wrapper #hero {
max-height: 400px;
overflow: hidden;
}
#menulink {
margin: 0;
text-align: center;
background-color: #1E1E1E;
}
#menulink a {
text-transform: uppercase;
color: white;
font-weight: 200;
text-decoration: none;
display: block;
padding-top: 0.1em;
padding-bottom: 0.1em;
}
nav {
position: relative;
}
#navlinks {
position: absolute;
width: 100%;
margin: 0;
padding: 0;
text-align: center;
background-color: rgba(0, 0, 0, 0.53);
}
#navlinks a {
display: block;
padding-top: 10px;
padding-bottom: 10px;
font-weight: 400;
text-decoration: none;
text-transform: uppercase;
}
#wrapper #hero img {
max-width: 100%;
}
figure {
width: 400px;
margin-left: auto;
margin-right: auto;
}
figure img {
max-width: 100%;
}
.grayscale {
filter: grayscale(100%);
}
.grayscale:hover {
filter: grayscale(0%);
}
<div id="wrapper">
<header>
<h1> Bayside Beat</h1>
<nav>
<h2 id="menulink"><a href="#navlinks">Menu</a></h2>
<ul id="navlinks">
<li> <a href="#"> Home </a></li>
<li> <a href="#">Sights </a></li>
<li> <a href="#">Dining </a></li>
<li> <a href="#">Events </a></li>
<li> <a href="#">Lodging </a></li>
</ul>
</nav>
</header>
<div id="hero">
<img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg">
<p>Bayside Beat keeps you informed of the best places to see, eat, and sleep in the City by the Bay.</p>
</div>
<main>
<h2>Riding the Cable Cars</h2>
<p> No visit to San Francisco is complete without a ride on the iconic cable cars that climb up the vertiginous hills of the city. Of the twenty-three lines established between 1873 and 1890, three remain: two routes from downtown near Union Square to
Fisherman's Wharf, and a third route along California Street.</p>
<p>The cable cars rely on cables running constantly beneath the road’s surface. The driver—or gripman—uses a lever to grip the cable to pull the car and its passengers up the hill. The gripman requires not only great strength, but also great skill. He
needs to know where to release the cable to coast over crossing cables and points. The conductor works in close cooperation with the gripman, operating the brake at the rear of the car to prevent it from running out of control on the downward slopes.</p>
<figure> <img src="http://www.hdwallpapers.in/walls/lotus_flowers-wide.jpg" class="grayscale">
<figcaption>The cable car terminus near Union Square.
</figcaption>
</figure>
<p>Although the cable cars are now mainly a tourist attraction, they’re still used by local commuters to get to and from work. The California Street line is particularly popular among commuters on weekdays. </p>
</main>
<aside>
<h2>Cable Car Tips</h2>
<p>A single ride on a cable car costs $7. If you plan to travel around the city, it’s often cheaper to buy a Muni Passport, which gives you unlimited rides on San Francisco’s extensive public transport system, including the cable cars (but not the BART
subway system). Even a single-day passport ($20) will save you money if you make a return trip, and stop off to visit Chinatown one way.</p>
<p>There are often long lines at the cable car terminus, particularly on the Powell-Mason and Powell-Hyde routes. If you don’t want to wait, try walking a few stops along the route. The conductor usually leaves a small number of places to pick up passengers
on the way. The California Street route is generally less crowded (but not as spectacular).</p>
</aside>
<footer>
<p>© Copyright 2013–16 Bayside Beat</p>
</footer>
</div>
关于html - 绝对定位元素的宽度百分比是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43446861/
我的理解是 width: 100% 让元素的宽度与其父元素的宽度相同,而 width: inherit 只有在明确指定父元素的宽度时才这样做.这种理解是否正确? 如果是这样,在我看来,当 width:
并设置“高度”为全屏的 1/2。 这是我的代码: div{ background:red; } 最佳答案 我会结合使用 css 和 javascript(使
编辑 2: 问题似乎出在规则的“bigTable”元素上。显然,在布局模板上使用时继承了错误的最小宽度。我仍在调查此事。 不过,我将再尝试一次 div。一个大问题是使用固定导航和动态内容,但我已经为此
我的网站需要显示宽表。在它上面是标题,它应该和整个页面一样宽(在这种情况下,和表格一样宽)。但是,它的宽度与视口(viewport)(屏幕尺寸)一样宽,因此显示时看起来还不错,但是一旦用户滚动到侧面,
我有一个小问题。我总是使用 float 来安排我的元素。我正在转向 flexbox,我做了一些例子,一切都很好,但我正在做一个事情进展不顺利的例子。 我有一个包含 1 到 12 种产品的容器,每行 4
例如,它们在自动边距方面会导致完全不同的行为。 看看这个 fiddle :https://jsfiddle.net/L1rk46xy/ .fixed { display:fixed;
我尝试在帖子中将段落的宽度设置为 75%,并将图像的响应宽度设置为 100%。然而,总是在 默认。 Some texts Some texts Some texts Some texts 目前,我只
HTML 元素可以有 width/height 属性,也可以有 CSS width/height 属性: HTML 属性和 CSS 属性有什么区别,它们应该具有相同的效果吗? 最佳答案 有关该主题的
我有一个流动的 table ,现在需要一个固定的 thead。问题是当你固定 thead 时,th-s 不尊重 tbody 的 td-s 的宽度。列的大小都由 BootStrap 处理。我已经阅读了很
我想像这样布置一个区域: ---- ---- |A | |B | | | | | ---- ---- --------- |C | --------- 三个盒子中的每一个都是 .盒子
我遇到了很多问题。 1) 我正在使用 Bootstrap-Select 来获得具有搜索功能的现代选择框,但无论我尝试什么,我似乎都无法获得填充 col-span 的选择。 2) 我已将该行拆分为 2
http://jsfiddle.net/95EtZ/1/ 问题在行动中解决了一半。 现在它是用 javascript 中硬编码的容器宽度设置的。 我需要 js 来获取容器 div 的宽度——使用窗口滚
我想要两个宽度和高度均为 100% 的 div。我知道子 div 不会工作,因为父 div 没有特定的高度,但有没有办法解决这个问题? HTML: CSS: body
我需要使用 jQuery 更改 的高度和宽度 我尝试了以下代码 jQuery('#chart_popup').css('height','600px'); jQuery('#chart_popup')
在自定义 WPF 控件中,我想将控件的宽度设置为高度的函数。例如:Width = Height/3 * x; 实现此目的的最佳方法是什么,以便控件正确且流畅地调整大小(和初始大小)? 最佳答案 您可以
我正在使用igraph在R中绘制图形,执行plot(mygraph, vertex.color = "green")之类的操作。 有没有办法改变顶点边界的颜色和/或宽度? 最佳答案 查看下面的代码;
有没有办法使用jquery设置图像的高度和宽度?以下是我的代码 var img = new Image(); // Create image $(img).load(function(){
这个问题类似于 how-to-find-the-actual-width-of-grid-component-with-scrollbar-in-delphi 但我无法获取 CalcDrawInfo(
这里是 HTML/CSS 新手。 试图将我在 Codeacademy 上学到的知识付诸实践,但我遇到了一个问题,即我设置为 width:100% 的 header 最终离开了页面。我相信这是因为边框,
这里是 HTML/CSS 新手。 试图将我在 Codeacademy 上学到的知识付诸实践,但我遇到了一个问题,即我设置为 width:100% 的 header 最终离开了页面。我相信这是因为边框,
我是一名优秀的程序员,十分优秀!