如何使用CSS添加背景图片标题?

时间:2016-10-15 03:14:04

标签: html css twitter-bootstrap

header {
   float: left;
   padding: 5px 0 0 0 ;
   width: 100%;
   background-image:url('../img/Kef_Beach.jpg');

}

我还需要添加背景图片标题。我怎样才能使用css添加。

1 个答案:

答案 0 :(得分:0)

将id或唯一类添加到该模式容器并应用css规则。如果没有工作......您可能需要将10-14 21:42:26.804 18552-18552/com.daprlabs.aaron.swipedeck2 E/UncaughtException: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference at com.daprlabs.aaron.swipedeck2.CardInfo.HoursActivity$HoursRecyclerViewAdapter$MyViewHolder.<init>(HoursActivity.java:97) at com.daprlabs.aaron.swipedeck2.CardInfo.HoursActivity$HoursRecyclerViewAdapter.onCreateViewHolder(HoursActivity.java:73) at com.daprlabs.aaron.swipedeck2.CardInfo.HoursActivity$HoursRecyclerViewAdapter.onCreateViewHolder(HoursActivity.java:57) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5836) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5060) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2843) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18834) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5953) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2685) at android.view.View.measure(View.java:18834) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2131) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1237) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1474) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1125) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6100) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:606) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5525) at java.lang.re 添加到更改的新属性中。

另请注意,如果您只是插入!important;,则不会覆盖所有css规则。您需要插入要覆盖的属性,例如.fade.in{}opacity

以此为例

&#13;
&#13;
background-color
&#13;
body{
background:green;
}
.modal-box{
  width:100px;
  height:100px;
  background:red;
  color:blue;
  opacity:1;
}
#override{
  background:blue;
  color:red;
  opacity:0.3;
}
&#13;
&#13;
&#13;

您在此代码段中注意到了什么?

我通过在模态框规则之后添加这些新规则来覆盖div的背景颜色,字体颜色和不透明度。