以图片和标题为中心

时间:2018-01-14 19:35:50

标签: html css

我致力于将图片居中并朝向头部。我想要的是将图片比标题高两倍。 我有一个在另一个上面:

<header>
  <div class="container">
    <img src="my_logo2.png" alt="Logo" class="logo">
    <h1>Auto Service</h1>
  </div>
</header>
Exceção fatal: android.app.RemoteServiceException
Bad notification for startForeground: java.lang.ClassCastException: int[] 
cannot be cast to android.app.PendingInten

android.app.ActivityThread$H.handleMessage (ActivityThread.java:1644)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6123)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run 
(ZygoteInit.java:867)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:757)

有人能解释我如何获得欲望结果吗?

2 个答案:

答案 0 :(得分:0)

是你想要的吗?

&#13;
&#13;
    <html>
	<style>
	.body{
      font: 15px/1.5 Arial, Helvetica, sans-serif;
      padding:0;
      margin:0;
      background-color:#f4f4f4;
    }
    header h1 {
      font: 400 100px/1.3 'Berkshire Swash', Helvetica, sans-serif;
      color: #2b2b2b;
      text-shadow: 1px 1px 0px #ededed, 4px 4px 0px rgba(0,0,0,0.15);
      border: 1px solid red;
    }

    .container {
      width: 90%;
      margin-left: 40px;
      margin-right: 0;
      padding: 0;
      overflow: hidden;
      border: 1px solid gray;
    }
   header{
      background: gray;
      text-align: center;
    }
    .logo{
       display: inline-block;
       margin: 0 auto;
       border: 1px solid white;
    }
	</style>
	<body>
	<header>
	<center>
      <div class="container">
        <Br><img src="my_logo2.png" alt="Logo" class="logo">
          <h1>Auto Service</h1>
          </div>
		  </center>
      </header>
	  <body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您想将商品置于div的中心吗?

.container {
  text-align: center;
}

img, h1 {
  margin: auto;
}