向左浮动并显示内联不起作用

时间:2018-05-05 20:27:51

标签: html css

我有一个问题,这意味着我的浮动左边没有工作,并删除了我的10%顶部填充。显示内联并不会将所有内容都推到最左边。有人可以解释一下我做错了什么吗?代码如下。



.outer {
  display: inline;
  padding-right: 5%;
  padding-left: 5%;
}

.galleryouter {
  padding-top: 10%;
  padding-right: 5px;
  padding-left: 5px;
  width: 30%;
  border: 2px solid black;
  border-radius: 8px;
}

.gallerypicture {
  width: 100%;
}

.galleryname {
  width: 100%;
}

.gallerydesc {
  width: 100%;
}

.galleryprice {
  width: 100%;
}

.gallerysold {
  width: 100%;
}

.galleryamount {
  width: 100%;
}

<?php
    if (isset ($_SESSION['Email']))
    {
	echo "";

    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "";


    $conn = new mysqli($servername, $username, $password, $dbname);

    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }

    $sql = "SELECT * FROM photos";
    $result = $conn->query($sql);


    $sql = "SELECT * FROM photos";
    $result = $conn->query($sql);

    if (mysqli_num_rows($result) > 0) {
	    while($row = mysqli_fetch_assoc($result)) {
    ?>


  <br/>
  <div class="outer">
    <div class="galleryouter" align="center">
      <div class="gallerypicture">
        <img src=<?php echo $row[ "picture"]; ?> width="50%">
        <br/>
        <div class="galleryname">
          <h1>
            <?php echo"'"; echo $row["Name"]; echo"'"; ?>
          </h1>
          <div class="gallerydesc">
            <p>
              <?php echo $row["Description"]; ?> </p>
            <div class="galleryamount">
              <p>
                <?php echo $row["Amount"]; ?> </p>
              <div class="gallerycost">
                <p>
                  <?php echo"£"; echo $row["Cost"]; ?> </p>
                <div class="gallerysold">
                  <p>
                    <?php echo $row["sold"]; ?> </p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

当您将(.galleryamount,.gallerysold等)设置为宽度:100%时。它正在扩展到容器的100%,这意味着不可能显示那些内联。删除那些宽度。

答案 1 :(得分:0)

编辑:我设法解决了这个问题。一切都在里面的div没有指定的宽度(我忘记了)