- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是初学者,在尝试对齐 img (#logo
) 和 carousel (#my-slider
) 时遇到了障碍 - 两者位于 #img-header
。
在它们下面有一个导航栏和一些文本。该网站的最大宽度应该是 1000px(img 的宽度是 350px,carousel 的宽度是 630px,所以可能它们都在 1000px 以下),但是当尝试对齐它们时,carousel 会跳到 Logo 下面.如果我尝试仅将旋转木马与导航栏和文本对齐,float:left
会起作用(如果我将最大宽度更改为 1060)但是,float:right
不会完全可以工作-无论我如何更改最大宽度,它都会向右移动。所有 3,导航栏,文本和 img-header 都应该同样宽。仅当我将 max-width 设置为 1880 时,img 和 carousel“同意”在同一行中,这也会使操纵杆偏向左侧而不是居中。我还尝试将 max-width
设置为 1000 并将 Logo 向左浮动,将旋转木马向右浮动,但它也不起作用 - 如果我将两者都 float 到同一侧,它也不起作用(例如, float:left;
.
This is how the website is supposed to look like- with this in the center.
HTML:
<div id="img-header">
<img id="logo" src="logo/logo3.png" style="width:350px;height:240px">
<div class="container">
<div class"row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide" data-ride="carousel" style="width:630px;height:240px">
<!-- indicators, small dots -->
<ol class="carousel-indicators">
<li data-target="#my-slider" data-slide-to="0" class="active"></li>
<li data-target="#my-slider" data-slide-to="1"></li>
<li data-target="#my-slider" data-slide-to="2"></li>
</ol>
<!-- wrapper for slides -->
<div class="carousel-inner" role="listenbox">
<div class="item active">
<img src="food/food1.jpg" alt="food 1">
</div>
<div class="item">
<img src="food/food2.jpg" alt="food 2">
</div>
<div class="item">
<img src="food/food3.jpg" alt="food 3">
</div>
</div>
<!--navigations/ next and prev buttons -->
<a class="left carousel-control" href="#my-slider" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<!--<span class="sr-only">Previous</span>-->
</a>
<a class="right carousel-control" href="#my-slider" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<!--<span class="sr-only">Previous</span>-->
</a>
</div>
</div>
</div>
</div>
</div>
CSS:
#img-header {
max-width: 1060px ;
margin-left: auto ;
margin-right: auto ;
}
#logo {
float: left;
}
#my-slider {
float: left;
}
#navbar {
max-width: 1000px ;
margin-left: auto ;
margin-right: auto ;
}
ul {
list-style-type: none;
overflow: hidden;
background-color: #125ea3;
}
li {
float: right ;
}
li:last-child {
border-right: none;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #3594ff;
}
.active {
background-color: #3594ff;
}
.text {
max-width: 1000px ;
margin-left: auto ;
margin-right: auto ;
}
h1 {
text-align="center"
}
p {
text-align="center"
}
我知道我只是一个初学者,所以我可能犯了很多错误,请提前原谅我。
提前感谢您的所有帮助和建议!
最佳答案
你有概率:
我想我已经发现了你的一些主要问题。首先,您的 div.row
类声明有错别字(缺少 =
“等号”)。
最大的问题是您的结构。我建议您进一步阅读 bootstrap 及其如何使用以下链接。
此外,我无法确定您的主要目标是关于响应度的,因此您有 3 个版本,它们都做不同的事情。如果我输入错误或忘记了什么,请告诉我。
这是我所做的:
我继续使用生成器(链接如下)重建您的 HTML
结构。我认为这没问题,因为您可能应该重新构建(是的,再次构建,如果您想了解其工作原理,请自行使用文档)无论如何都要重新构建布局 2 次。
演示:
http://codepen.io/anon/pen/VjdRJK
(版本 1)http://codepen.io/anon/pen/QExPmP
(版本 2)http://codepen.io/anon/pen/PzaLwk
(版本 3)
延伸阅读:
Bootstrap
)Bootstrap
的快速分解(下)
Bootstrap
的快速分解:Bootstrap
是一个非常漂亮的系统,但我经常看到它变得过于复杂并且此后使用不当。我认为如果我们简化有关 Bootstrap
实际是什么的事情,以便使问题更加清晰,那将会很有帮助。如果需要,我会写更多。
首先:
Bootstrap
是一个框架
:
Bootstrap
只是一个预制的基础结构,您的代码就是基于该结构构建的。Bootstrap
旨在定制。此链接将向您显示:http://getbootstrap.com/customize/ (为了方便也放在列表中)jQuery
插件或Javascript
组件
。 HTML
、CSS
和 Javascript
Consider this Analogy: it's best to use a concrete foundation to construct a building upon - although it's certainly possible to build a house without a rock-solid, ground-embedded concrete base of a foundation, it certainly won't adapt to & survive the future storms of obsoletion and changes to the land.
The meaning behind it: Not that it's impossible to create a great front-end presentation without them, but frameworks like
Bootstrap
totally rock. They address a multitude of potential issues and problems related to possibly unexpected results, they take care of a lot of the repeated, preamblic code, and they're incredibly flexible: able to be customized, reduced, enhanced, etc.Often Overlooked: One hidden
gem
/benefit is thatBootstrap
(much like every other widely-usedframework
/system, likeDrupal
,Magento
, orWordpress
) inherently creates a reliably (usually) consistent set of standards that aren't only easy for (almost) everyone to adhere to (most without even knowing it) but are also easy for (almost) everyone to understand (like when debugging for others on StackOverflow).
Bootstrap
只是有一堆额外的东西:无论你在做什么,他们都不知道你到底需要什么,但他们做了一个很好的假设毫无疑问,它会包括 grid
系统、image
和一些 component
的使用,例如 jumbotron
或 callout
。该选项由您自己决定,您在自定义 Bootstrap
下载中做什么(和)不包括什么。
就是这样。这些是基础知识。它没有什么疯狂的,除了一些奇妙的创新洞察力,由它的创造者提供。虽然它比您信任的 ol'e CSS Reset
和 CSS Normalize
处理的更多,但如果您将它当作 CSS Reset
super 代码类固醇。
就是这样!
关于html - 如何将 img 和 carousel 并排对齐,最大宽度为 1000px?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635425/
我想替换每一个 带结束标记 字符串中的标记。该字符串实际上是一个 html 文档,其中 img 标记由我生成,并且始终如下所示: Src 是用户输入,所以它可以是任何东西。我做了一个正则表达式,不确
我使用数组通过 getElementsByClassName 存储我所有的 imgs。 我需要知道哪个 img 被点击或 mouseover/mouseout,所以我使用循环来检查哪个 img 被点击
我正在尝试使用图像制作一款类似 Match3 的游戏,但我无法进行比较。我正在为固定数量的 atm 执行此操作,只是为了让它正常工作,稍后应该在 foreach 循环中。如果有什么区别的话,该函数位于
我希望你能帮助我:) 我想定义 img 的高度,相对于图像的“实际”宽度。但宽度是动态的,因为它占父对象的百分比(wxample 的浏览器窗口)。 为什么我需要高度?:没有高度它工作正常,但我需要它,
我知道这个话题被讨论了很多,但我找不到任何适合我的解决方案。所以,我的代码大致是: var img =me.images[curID] var f = function() { var
我试图在一个页面上列出多个图像,但当您单击图像时,它会以模式打开。 它适用于第一张图片,但不适用于其他图片,我假设这是一个 JS 问题,我尝试设置一个空的 var,然后将其设置为获取元素 ID(每个
任务:我们正在通过 HttpWebRequest 抓取 HTML 内容(约 6,000 个调用)。该字符串经过修剪并存储在 SQL Server 2014 数据库中,以便作为 XML 进行处理。 问题
我从上面得到这个错误,不知道如何避免它。我的目的是获取屏幕截图,然后对其进行模板匹配,以查看此时屏幕上是否显示图标。到目前为止,它只是图标的位置。我的代码: #include "opencv2/hig
我有一个包含图像的容器,该图像是从应用程序加载的,因此容器的尺寸是已知的,而图像会有所不同。 我目前有以下 css: #secondary_photos { height: 100px; wi
我正在尝试设置一个随分辨率缩放但看起来仍然不错的页面背景..这就是我正在使用的.. 站点是http://www.gd-gaming.com/wordpress ,如果你用 Firebug 检查它,它只
目前我有 如何删除包装 img 标签的 p 标签? 所以我可以得到.. 最佳答案 使用 $('p > img').unwrap(''); 这将删除 img 周围的所有 p。您应该使用 cl
我想要动画 3 .svg图片: 和css : .sequence { position: relative; } .sequence img { position: ab
我有外部 RSS 提要填充以下重复出现的类 elements 。 {teaserImage} {teaserImage} {teaserImage} 我想简单地获取 :first 实例,该实例也是来自
这是一个独特的问题: 我不想使用浏览器 JavaScript 来解决这个问题,请继续阅读... 我要转换 通过编译应用程序( ng build 或 ng serve )到 Base64 img 标签,
悬停在 中的第一张图片上标记,我需要使用 CSS 增加第二张图片的不透明度。我试过使用 +和 ~运营商,无法让它发挥作用。任何帮助将不胜感激。 最佳答案 a:hover + img
我已经尝试解决这个问题有一段时间了,但我迷路了,有人吗? for(var i=0; i<10; i++) { var Img = new Image(); Img.onload = (
这就是我想要实现的目标: 当用户将鼠标悬停在较小的图像之一上时: 较小的图像 + 文本应替换较大的图像 + 文本。 当用户没有悬停时;将大集返回到其原始图像和文字。 这就是我到目前为止所拥有的。它没有
我知道如何在 php 中执行此操作,但我需要在 javascript/jquery 中完成此操作。 我正在尝试执行以下操作: $('#NewBox').html( $('#OldBox').html(
我正在使用一个 CMS (ExpressionEngine),它将段落标签包裹在图像周围。我正在使用响应式图像(最大宽度:100%),并且由于我还在段落上定义宽度,因此它会导致问题。我想使用 jQue
Tinymce 正在删除我的 img 结束标记并生成无效的 xhtml。 它变成了这个 进入这个 我也在使用 codemagic,但是在查看 html 时它仍然显示 .我也试过包括 , 但输出是
我是一名优秀的程序员,十分优秀!