并排问题(Div side by side issue)

我的CSS有问题 - 我有两个div - “section1”和“section2”。 我希望它们并排显示,但它们正如图所示显示。 有谁知道如何并排显示它们?

问题

  <div id="section1">
   <h1><London></h1>
    <p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants</p>
  </div>

  <div id="section2">
  <h2><London></h2>
  <p1>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants</p>
 </div>

</div>

#section1
{
float:center;
padding:5px;
background-color:lime; 
margin-left:20px;
width:300px; 
}

#section2
{
float:right;
background-color:lime; 
margin-left:10px;
width:300px;
}

I have an issue with my CSS - I am have two divs - "section1" and "section2". I want them to be displayed side by side but they are being displayed as seen in the picture. Does anyone know how to display them side by side?

issue

  <div id="section1">
   <h1><London></h1>
    <p>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants</p>
  </div>

  <div id="section2">
  <h2><London></h2>
  <p1>London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants</p>
 </div>

</div>

#section1
{
float:center;
padding:5px;
background-color:lime; 
margin-left:20px;
width:300px; 
}

#section2
{
float:right;
background-color:lime; 
margin-left:10px;
width:300px;
}

原文:https://stackoverflow.com/questions/35977486
2022-01-06 14:01

满意答案

Google最近宣布设计支持库 ,并且它支持实施Collapsing Toolbar

除了固定视图外,您还可以使用app:layout_collapseMode="parallax" (以及可选的app:layout_collapseParallaxMultiplier="0.7"来设置视差乘数),以实现视差滚动(在CollapsingToolbarLayout中表示同级ImageView)

例:

<android.support.design.widget.AppBarLayout
        android:layout_height="192dp"
        android:layout_width="match_parent">
    <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <android.support.v7.widget.Toolbar
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>
        </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

Google has recently announced Design support library and with this it has support for implementing Collapsing Toolbar.

In addition to pinning a view, you can use app:layout_collapseMode="parallax" (and optionally app:layout_collapseParallaxMultiplier="0.7" to set the parallax multiplier) to implement parallax scrolling (say of a sibling ImageView within the CollapsingToolbarLayout)

Example:

<android.support.design.widget.AppBarLayout
        android:layout_height="192dp"
        android:layout_width="match_parent">
    <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <android.support.v7.widget.Toolbar
                android:layout_height="?attr/actionBarSize"
                android:layout_width="match_parent"
                app:layout_collapseMode="pin"/>
        </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

相关问答

更多

如何做新的PlayStore视差效果(How to do the new PlayStore parallax effect)

Google最近宣布设计支持库 ,并且它支持实施Collapsing Toolbar 。 除了固定视图外,您还可以使用app:layout_collapseMode="parallax" (以及可选的app:layout_collapseParallaxMultiplier="0.7"来设置视差乘数),以实现视差滚动(在CollapsingToolbarLayout中表示同级ImageView) 例: <android.support.design.widget.AppBarLayout ...

纯CSS视差效果问题(Pure CSS Parallax effect issue)

我相信效果( parallax与否)不起作用的原因是因为你使用<body>作为主元素。 可能它使用的某些属性对<body>没有影响。 我假设我们正在谈论perspective和它的供应商前缀对应物。 显而易见的解决方法是使用<div>作为主机,而不是<body> 。 我试图使用你链接的网站上的一些样式和图像,但它看起来不太好。 你知道了。 I believe the reason the effect (parallax or not) does not work is because you u...

在Materialise.css中获取视差效果需要任何特殊图像吗?(Do you need any special image for getting Parallax effect in Materialize.css?)

我在这里更新您的小提琴https://jsfiddle.net/nmdd876c/2/ 一切安好。 我只清理你的HTML并纠正你的外部资源。 <!-- Compiled and minified CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css"> <!-- Compiled and minified Java...

自举网格中的视差效果(Parallax effect within bootstrap grid)

这是你的答案 你需要使用jquery 检查这个https://codepen.io/parthjasani/pen/YZwJMq remove background-attachment: fixed; from css 并添加此jquery代码 var $ = jQuery.noConflict() $(window).scroll(function(){ var scroll = $(this).scrollTop() $(".parallax").css({"backgro...

CSS转换的视差效果(Parallax effect with CSS transition)

CSS具有perspective属性,您可以将其与zoom功能结合使用,以实现元素“后面”或“前面”的其他元素,从而以不同的速度滚动。 有很多关于这方面的资源,@ dwreck08给出的是最好的资源之一: http ://keithclark.co.uk/articles/pure-css-parallax-websites/ 这是一个快速复制: .parallax { height: 100vh; overflow-x: hidden; overflow-y: auto; ...

使用recyclerView的视差效果(Parallax effect with recyclerView)

确保您使用的是com.android.support:recyclerview-v7:22.2.0 如果不是更新它 Make sure you're using com.android.support:recyclerview-v7:22.2.0 if not than update it

视差效果不会起作用(Parallax effect wont work)

代码很难阅读,也许发布到CodePen.io。 我发现创建视差效果最简单的方法是使用Skrollr.js 。 这是一个简单的视差滚动教程 。 I solved the problem. var diffheight = $divs.eq(0).height() - liHeight; Spelled diffHeight with a small "h" and when i used it i called it with a big "H" scroll = ~~(offset/liHeigh...

文本的视差效应(Parallax Effect on Text)

我会使用你的scrollPos变量来操纵CSS属性transform: translateY(n); 像这样的东西: var transY = scrollPos / 2; $('.page-title').css('transform':'translateY(' + transY + ')'); 当然可以使用数字来获得所需的效果。 Transform CSS属性有助于提高性能( https://www.paulirish.com/2012/why-moving-elements-with-t...

iPad和视差效果(iPad and parallax effect)

我也正在研究视差,并意识到它只适用于iOS设备。 可能与Nike Better World视差网站在移动设备上观看静态图像的原因相同。 其他人已经解决了这个问题并且可能有所帮助: CSS“position:fixed;” 在iPad / iPhone上? I am also working on a parallax and have realized that it just doesn't work on iOS devices. Probably the same reason the Ni...

具有视差效果的图像尺寸问题(Image size issue with parallax effect)

设置background-size: 100% auto .parallax类background-size: 100% auto .parallax { background-attachment:fixed; background-size: 100% auto; } 福克: http : //jsfiddle.net/r7oyxL92/ set background-size: 100% auto for .parallax class .parallax { back...

相关文章

更多

Riak, haproxy, and client side applications

转载:http://blog.dloh.org/Riak,-haproxy,-and-client-s ...

gwt 部署在div 中的问题。

按照这片文章(http://developerlife.com/tutorials/?p=231)将我 ...

div 与 iframe页面缩小问题 [JavaScript]

&lt;div width=&quot;20%&quot;&gt;&lt;/div&gt; &lt; ...

如何用正则表达示匹配一个div标签

如何用正则表达示匹配一个div标签

div布局代替frame布局后该如何跳转呢?

进入base.jsp页面后,frame可以分别跳转到top,left,right,bottom之类的子 ...

jquery 效果实现,div失去焦点

我想做一个弹出层.input的失去焦点的时候. [点击层内的link不关闭该层.点击该层外则关闭该层] ...

《DIV.CSS应用视频教程》(DIV+CSS)[压缩包]

中文名: DIV.CSS应用视频教程 英文名: DIV+CSS 资源格式: 压缩包 ...

Flex 如何输出日志

我们在编写Flex应用程序的时候经常会忽略logging,发现问题需要debug的时候用的最多的就是A ...

解决点击没有内容的空白div没有响应click事件的方法

给一个div绑定一个click事件,如果这个div没有内容,在一般浏览器下都没有问题,在IE8下点击的 ...

html中一个div的id是“1:222”的话,怎么利用id给它定义css啊?

如 &lt;style&gt; #1:2{ height:100px; width:100px ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本