Menu
So like I want to add an image above a rectangle div. But how do you do this? And how do you make it always to the right? And tilted a little. It’s a little face peeking out above a dialogue box. How do I do this? And like screen size friendly?
>@Bost#1644192
>
> I was imagining something a little more like this:
>I just now tried adding a <br> in between the containers to match the concept image I made, but nothing happened. How do I do that?
flex-direction
</C> to <C>
column
</C>:
<CODE>
`<i>
</i>#container {
display: flex;
flex-direction: column;
}<i>
</i>
``#container > div
height: 50vh;
flex: 1;
`>@Bost
>
> how do I make them each half of the screen?
>@Bost#1644268
> That doesn't take up half of the screen... (vertically)
``<i>
</i>body>div {
position: relative;
display: flex;
flex-direction: column;
}<i>
</i>
``
>@Sempervivum#1644403 The large button is covering the text.
.dialogue:last-of-type button {right: 0.25em}
.dialogue button:last-of-type { right: 1; }
>@Sempervivum#1644403 Regarding the large button it might be more appropriate not to use absolute positioning but place it below the text by flex layout.
flex-direction: row;
</C> is default, thus it is sufficient when you apply <C>
display: flex;
</C> to the container:
<CODE>
`<i>
</i>body>div {
position: relative;
display: flex;
flex-direction: row; /* can be omitted as it's default */
}<i>
</i>
``>@coothead#1644504 How is the code todetermine when the dialogue box is not needed?
>@Bost#1644500 Maybe I could just set background url to none and display hide that button as well? then when it's needed again set the url back and display block the button?
>@Bost#1644524 How I thought to go about it,
>
>[Bost](https://www.webdeveloper.com/forum/d/399869/33) Maybe I could just set background url to none and display hide that button as well? then when it's needed again set the url back and display block the button?
>
> works, right? Or a better way ?
``javascript<i>
</i>document.body.classList.add("showBg")
window.addEventListener('keydown', function() {
document.getElementById("bottom").style.visibility = 'hidden'
document.body.style.background = 'none'
document.body.classList.remove("showBg")
})
window.addEventListener('keyup', function() {
document.getElementById("bottom").style.visibility = 'visible'
document.body.style.background = 'url(https://www.coothead.co.uk/images/face-and-line.png)'
document.body.classList.add("showBg")
})<i>
</i>
`</CODE>
And at the top of the css:
<CODE lang="css">
`css<i>
</i>.showBg {
background-image: url( https://www.coothead.co.uk/images/face-and-line.png );
background-position: center right;
background-repeat: no-repeat;
}<i>
</i>
``
``javascript<i>
</i> var n = 1
window.addEventListener('keyup', function() {
document.body.classList.toggle("showBg")
if (n == 1) {
n = 2
document.getElementById("bottom").style.visibility = 'visible'
} else {
n = 1
document.getElementById("bottom").style.visibility = 'hidden'
}
})<i>
</i>
``
0.1.9 — BETA 4.26