mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:07:43 +00:00
LibWeb: Improve media document styling to center image
This commit is contained in:
parent
042d3b79c2
commit
e33ae9a58b
1 changed files with 18 additions and 0 deletions
|
@ -335,6 +335,24 @@ static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOM::Document>> load_media_document(
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto style_element = TRY(DOM::create_element(document, HTML::TagNames::style, Namespace::HTML));
|
||||||
|
style_element->set_text_content(R"~~~(
|
||||||
|
:root {
|
||||||
|
background-color: #222;
|
||||||
|
}
|
||||||
|
img, video, audio {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
max-height: 100vh;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
)~~~"_string);
|
||||||
|
TRY(document->head()->append_child(style_element));
|
||||||
|
|
||||||
auto url_string = document->url_string();
|
auto url_string = document->url_string();
|
||||||
if (type.is_image()) {
|
if (type.is_image()) {
|
||||||
auto img_element = TRY(DOM::create_element(document, HTML::TagNames::img, Namespace::HTML));
|
auto img_element = TRY(DOM::create_element(document, HTML::TagNames::img, Namespace::HTML));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue