html - Safari handles fit-content dialogs wrapping height: 100% as having no height - Stack Overflow
I have a HTML dialog element .parent
containing an inner div .child
. The parent has height: fit-content
while the child has height: 100%
. In other browsers, the height of the elements are computed as some nonzero value fitting the content of .child
. However, in Safari, .child
's height is being computed as 0. What's going on here?
In this snippet, I've colored .child
's background green. I expect the green to be visible,indicating nonzero height.
.parent {
height: fit-content;
}
.child {
height: 100%;
background-color: lightgreen;
}
<dialog open class="parent">
<div class="child">
Content
</div>
</dialog>
I have a HTML dialog element .parent
containing an inner div .child
. The parent has height: fit-content
while the child has height: 100%
. In other browsers, the height of the elements are computed as some nonzero value fitting the content of .child
. However, in Safari, .child
's height is being computed as 0. What's going on here?
In this snippet, I've colored .child
's background green. I expect the green to be visible,indicating nonzero height.
.parent {
height: fit-content;
}
.child {
height: 100%;
background-color: lightgreen;
}
<dialog open class="parent">
<div class="child">
Content
</div>
</dialog>
Share
Improve this question
edited Nov 15, 2024 at 19:53
j08691
208k32 gold badges269 silver badges280 bronze badges
asked Nov 15, 2024 at 19:43
tau_tau_
233 bronze badges
1
- 1 Did you figure this out? I have been also struggling with this in safari. If I don't specify a height in the dialog element, safari treats it as 0, while in the other browsers it will fit the content. If I set height: auto, it kind of works but still doesn't fit all the content as expected but at least it shows some height. – Carlos Sosa Commented Nov 17, 2024 at 16:35
1 Answer
Reset to default 0I was also struggling with this issue, if instead of height: 100% on the child element, use min-height: 100% that should work.
.parent {
height: fit-content;
}
.child {
min-height: 100%;
background-color: lightgreen;
}
<dialog open class="parent">
<div class="child">
Content
</div>
</dialog>
- 安卓之父曾遭三星高管嘲笑:你们喝醉了吗
- Computex 2012:Windows 8将怎样改变PC行业
- swift - Load Flutter assets in iOS - Stack Overflow
- laravel - Filament | Processing Attachment using API through Email via SendGrid - Stack Overflow
- How to solve input buffer for assembly - Stack Overflow
- ios - Flutter: works on Xcode but not on VS code and Android Studio - Stack Overflow
- python - How to fix autocomplete menu flickering in PyCharm on Linux? - Stack Overflow
- python - Trouble implementing Hamitonian with QutiP - Stack Overflow
- python - Converting Document Docx with Comments to markit using markitdown - Stack Overflow
- python - Having issues getting django-simple-captcha to work on my Contact Us page - Stack Overflow
- php - New default Moodle setup, no cssimages? - Stack Overflow
- wordpress - Give access to users own submitted entries only wpforms - Stack Overflow
- google cloud platform - Java application unable to find ADC when Workload Identity is enabled on GKE cluster - Stack Overflow
- node.js - How to extract frames in sequence as PNG images from ffmpeg stream? - Stack Overflow
- innodb - How does MySQL handle lock queuing order for SELECT ... FOR UPDATE? - Stack Overflow
- How to Use GraalVM to Execute JavaScript Code Making REST Calls Using Java? - Stack Overflow
- Conflicting dependencies while installing torch==1.10.0, torchaudio==0.10.0, and torchvision==0.11.0 in my Python environment -