Bootstrap 4布局,标头上有卡片

时间:2017-04-29 09:33:30

标签: html5 twitter-bootstrap css3 twitter-bootstrap-4

我正在尝试使用3张卡片和标题创建简单的布局。 3张卡应该全部在一行中,但中间的卡应该更大(它应该具有比其他两个更大的高度和重量)并且应该重叠头部。默认情况下,在bs4中创建的所有卡都是相同的。我应该为每张卡设置属性吗?你能帮帮我吗?感谢。

以下是plunker link

    <header role="banner" class="header-test">
  <h1>Test layout</h1>
</header>

<div class="row">
  <div class="col-3">
    <div class="card custom-card-style">
      <div class="card-block">
        <h4 class="card-title">Card title</h4>
        <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
          content.</p>
        <a href="#" class="card-link">Card link</a>
        <a href="#" class="card-link">Another link</a>
      </div>
    </div>
  </div>
  <div class="col-6">
    <div class="card custom-center-card-style">
      <div class="card-block">
        <h4 class="card-title">Card title</h4>
        <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
          content.</p>
        <a href="#" class="card-link">Card link</a>
        <a href="#" class="card-link">Another link</a>
      </div>
    </div>
  </div>
  <div class="col-3">
    <div class="card custom-card-style">
      <div class="card-block">
        <h4 class="card-title">Card title</h4>
        <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's
          content.</p>
        <a href="#" class="card-link">Card link</a>
        <a href="#" class="card-link">Another link</a>
      </div>
    </div>
  </div>
  </div>

1 个答案:

答案 0 :(得分:0)

使用此功能非常有效。

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relative"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/topRl"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="@color/white">

        <Button
            android:id="@+id/backBtn"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_centerVertical="true"
            android:layout_marginLeft="15dp"
            android:background="@drawable/back_arrow" />

        <TextView
            android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:text="@string/register_heading"
            android:textColor="@color/black"
            android:textSize="@dimen/text_size_for_heading" />
    </RelativeLayout>

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="3px"
        android:background="@drawable/shadow_down"
        />

    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:id="@+id/mainLinear"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:gravity="center_horizontal"
            android:orientation="vertical">

            <Button
                android:id="@+id/registerWithFacebookBtn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="20px"
                android:background="@drawable/blue_dark_btn_selector"
                android:text="@string/register_with_facebook"
                android:textColor="@drawable/white_color_selector"
                android:textSize="@dimen/text_18sp" />

            <LinearLayout
                android:id="@+id/etLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="10dp"
                android:gravity="center_horizontal"
                android:orientation="vertical"
                >


                    <EditText
                        android:id="@+id/firstNameEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/first_name"
                        android:imeOptions="actionNext"
                        android:inputType="textPersonName|textNoSuggestions|textCapSentences"
                        android:maxLines="1"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />

                    <EditText
                        android:id="@+id/lastNameEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5px"
                        android:hint="@string/last_name"
                        android:inputType="textPersonName|textNoSuggestions|textCapSentences"

                        android:maxLines="1"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />



                <!--<RelativeLayout
                    android:id="@+id/rlCountryCode"
                    android:layout_width="150px"
                    android:layout_height="@dimen/edit_text_height"
                    android:layout_alignParentLeft="true">

                    <TextView
                        android:id="@+id/tvCountryCode"
                        android:layout_width="match_parent"

                        android:layout_height="match_parent"
                        android:layout_marginTop="5px"
                        android:background="@drawable/edit_text_bg"
                        android:gravity="center"
                        android:paddingLeft="20px"
                        android:paddingRight="20px"
                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textSize="@dimen/text_size_edit_text" />

                    <Button
                        android:id="@+id/button1"
                        style="?android:attr/buttonStyleSmall"
                        android:layout_width="14px"
                        android:layout_height="11px"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:layout_marginRight="10px"
                        android:background="@drawable/down_arrow_btn_selector"
                        android:clickable="false"
                        android:duplicateParentState="true" />

                </RelativeLayout>-->

                    <EditText
                        android:id="@+id/phoneNoEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_marginTop="5px"
                        android:layout_toRightOf="@+id/rlCountryCode"
                        android:digits="0123456789"
                        android:hint="@string/phone_number"
                        android:inputType="phone|textNoSuggestions"
                        android:maxLength="10"

                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />


                    <EditText
                        android:id="@+id/emailIdEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5px"
                        android:hint="@string/email_id"
                        android:inputType="textEmailAddress"

                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />


                    <EditText
                        android:id="@+id/passwordEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5px"
                        android:hint="@string/password"
                        android:inputType="textPassword"

                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />


                    <EditText
                        android:id="@+id/confirmPasswordEt"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5px"
                        android:hint="@string/confirm_password"
                        android:inputType="textPassword"

                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />

                    <EditText
                        android:id="@+id/aboutUsET"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5px"
                        android:hint="@string/hear_about_us"
                        android:inputType="textEmailAddress"

                        android:singleLine="true"
                        android:textColor="@color/edit_text_text_color"
                        android:textColorHint="@color/edit_text_hint_color"
                        android:textCursorDrawable="@drawable/color_cursor"
                        android:textSize="@dimen/text_size_edit_text" />


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:paddingBottom="3dp"
                    android:layout_marginLeft="20px"
                    android:layout_marginRight="20px"
                    android:paddingTop="5dp">

                    <CheckBox
                        android:id="@+id/agree_chk"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:button="@drawable/check_box_selector"
                        android:padding="5dp"
                        android:text="@string/agree_text"
                        android:textColor="@color/black"
                        android:textSize="12sp"
                        android:textStyle="bold"/>

                    <TextView
                        android:id="@+id/terms_of_use_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/terms_of_use"
                        android:textColor="@color/black"
                        android:textSize="12sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/and_text"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5dp"
                        android:text="and"
                        android:textColor="@color/black"
                        android:textSize="12sp"
                        android:textStyle="bold"/>


                </LinearLayout>

                <TextView
                    android:id="@+id/privacy_policy_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left"
                    android:layout_marginLeft="40dp"
                    android:text="@string/privacy_policy"
                    android:textColor="@color/black"
                    android:textSize="12sp"
                    android:textStyle="bold" />
            </LinearLayout>

            <Button
                android:id="@+id/signUpBtn"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/btn_corner_margin"
                android:layout_marginTop="@dimen/btn_corner_margin"
                android:background="@drawable/blue_dark_btn_selector"
                android:text="@string/register"
                android:textColor="@drawable/btn_text_color_selector"
                android:textSize="@dimen/button_text_size"
                />


        </LinearLayout>

    </ScrollView>


</LinearLayout>