居中div和从右到左的图片

时间:2018-07-02 19:31:13

标签: html css

我想在标题div的右边放一张图片。 无法执行。你能帮我吗?

div的宽度为80% 并以“保证金:0 10%;”为中心

HTML代码:

$stmt = $con->prepare("SELECT email, name FROM public_users WHERE email = ? OR name = ?");
$stmt->bind_param('ss', $email, $name);

  

CSS代码:

<html>
<head>
    <title> Yakir Freed </title>
    <link rel="stylesheet" href="css/style.css">
    <img id="logo" src="images/logo.png" alt="Yakir Freed" />
    <div id="header">
    </div>
</head>

1 个答案:

答案 0 :(得分:0)

右对齐红色框标题的外部吗? 可以这样做,然后将left: -279px更改为徽标的宽度

body {
  background-color: darkgray;
  background-image: url('../images/website.jpg');
  background-repeat: repeat-x;
}

#logo {
  position: absolute;
  display: inline-block;
  left: -279px;
  top: 0px;
  z-index: 2;
}

#header {
  position: fixed;
  display: inline-block;
  margin: 0 10%;
  top: 0px;
  width: 80%;
  height : 150px;
  background: rgb(217, 47, 54);
  z-index: 1;
}
<html>
<head>
    <title> Yakir Freed </title>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div id="header">
          <img id="logo" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Yakir Freed" />
    </div>
</body>
</html>

相关问题