Положение: абсолют и положение: родственник не работает

вы можете перейти к концу вашего файла с помощью f.seek (0, 2), а затем прочитать строки поочередно со следующей заменой readline ():

def readline_backwards(self, f):
    backline = ''
    last = ''
    while not last == '\n':
        backline = last + backline
        if f.tell() <= 0:
            return backline
        f.seek(-1, 1)
        last = f.read(1)
        f.seek(-1, 1)
    backline = last
    last = ''
    while not last == '\n':
        backline = last + backline
        if f.tell() <= 0:
            return backline
        f.seek(-1, 1)
        last = f.read(1)
        f.seek(-1, 1)
    f.seek(1, 1)
    return backline
-4
задан Arshiya Khanam 19 March 2019 в 10:11
поделиться

4 ответа

Так как у вас было bottom:0 - .header, высота его увеличивалась к вершине. Надеюсь, что это помогает благодаря

.announce {
  height: 45px;
  width: 100%;
  position: relative;
}

.header {
  position: absolute;
  height: 130px;
  background: blue;
  width: 100%;
  /* bottom: 0; */
}
<div class="announce">
  <div class="header">
    <img src="img/logo.png" alt="image">
  </div>
</div>

0
ответ дан Xenio Gracias 19 March 2019 в 10:11
поделиться

Я добавил код согласно вашему эталонному изображению. Вы можете настроить высоту announce и header по желанию.

.announce {
    height: 45px;
    width: 100%;
    position: relative;
}

.header {
    background: blue;
    width: 100%;
    height: 50px;
}

.header img {
    max-width: 100%;
    max-height: 50px;
}
<div class="announce">
    <div class="header">
        <img src="https://via.placeholder.com/300x100">
    </div>
</div>

0
ответ дан Saravana 19 March 2019 в 10:11
поделиться

вложенные div не могут быть размещены независимо. Есть два отдельных элемента. рассмотрим следующее.

announce {
  height: 45px;
  width: 100%;
  position: relative;
}

.header {
  position: absolute;
  height: 130px;
  background: blue;
  width: 100%;
  bottom: 0;
}
<div class="announce">
  This is some announcement
</div>
 <div class="header">
  <img src="img/logo.png">
</div>

0
ответ дан Prakhar Singh 19 March 2019 в 10:11
поделиться

Вы должны указать поле .header img

.announce {
  position: relative;
  height: 45px;
  width: 100%;
}
.header {
  position: absolute;
  height: 130px;
  background: blue;
  width: 100%;
  bottom: 0;
}
.header img {
  margin: 82px 5px 0;
}
<div class="announce">
<div class="header">
<img src="img/logo.png">
</div>
</div>

0
ответ дан Arshiya Khanam 19 March 2019 в 10:11
поделиться