首页 \ 问答 \ 并排问题(Div side by side issue)

并排问题(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>

相关问答

更多