mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-27 15:19:52 +02:00
Add new .overflow-x
, .overflow-y
, and object-fit utilities
Overflow utilities are self-explanatory. The object-fit property is used to specify how an `<img>` or `<video>` should be resized to fit its container. Offers a responsive alternative to using `background-image` for a resizable fill/fit image.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
{{- $show_markup := .Get "show_markup" | default true -}}
|
||||
{{- $show_preview := .Get "show_preview" | default true -}}
|
||||
{{- $input := .Inner -}}
|
||||
{{- $content := .Inner -}}
|
||||
|
||||
<div class="bd-example-snippet bd-code-snippet">
|
||||
{{- if eq $show_preview true -}}
|
||||
@@ -40,7 +41,8 @@
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- $content := replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>\n` `<img src="..." class="$1" alt="...">` $input -}}
|
||||
{{- $content = replaceRE `<svg class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?<\/svg>` `<img src="..." class="$1" alt="...">` $content -}}
|
||||
{{- $content = replaceRE `<img class="bd-placeholder-img(?:-lg)?(?: *?bd-placeholder-img-lg)? ?(.*?)".*?/>` `<img src="..." class="$1" alt="...">` $content -}}
|
||||
{{- $content = replaceRE ` (class=" *?")` "" $content -}}
|
||||
{{- highlight (trim $content "\n") $lang "" -}}
|
||||
{{- end -}}
|
||||
|
@@ -4,11 +4,12 @@
|
||||
`args` are all optional and can be one of the following:
|
||||
* title: Used in the SVG `title` tag - default: "Placeholder"
|
||||
* text: The text to show in the image - default: "width x height"
|
||||
* class: Class to add to the `svg` - default: "bd-placeholder-img"
|
||||
* class: Class to add to the `svg` or `img` - default: "bd-placeholder-img"
|
||||
* color: The text color (foreground) - default: "#dee2e6"
|
||||
* background: The background color - default: "#868e96"
|
||||
* width: default: "100%"
|
||||
* height: default: "180px"
|
||||
* markup: If it should render `svg` or `img` tags - default: "svg"
|
||||
*/ -}}
|
||||
|
||||
{{- $grays := $.Site.Data.grays -}}
|
||||
@@ -26,8 +27,19 @@
|
||||
{{- $show_title := not (eq $title "false") -}}
|
||||
{{- $show_text := not (eq $text "false") -}}
|
||||
|
||||
<svg class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" width="{{ $width }}" height="{{ $height }}" xmlns="http://www.w3.org/2000/svg"{{ if (or $show_title $show_text) }} role="img" aria-label="{{ if $show_title }}{{ $title }}{{ if $show_text }}: {{ end }}{{ end }}{{ if ($show_text) }}{{ $text }}{{ end }}"{{ else }} aria-hidden="true"{{ end }} preserveAspectRatio="xMidYMid slice" focusable="false">
|
||||
{{- if $show_title }}<title>{{ $title }}</title>{{ end -}}
|
||||
<rect width="100%" height="100%" fill="{{ $background }}"/>
|
||||
{{- if $show_text }}<text x="50%" y="50%" fill="{{ $color }}" dy=".3em">{{ $text }}</text>{{ end -}}
|
||||
</svg>
|
||||
{{- $markup := .Get "markup" | default "svg" -}}
|
||||
|
||||
|
||||
{{- if eq $markup "img" -}}
|
||||
<img class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" alt="{{ $title }} : {{ $text }}" width="{{ $width }}" height="{{ $height }}" src="data:image/svg+xml,%3Csvg style='font-size: 1.125rem; font-family:system-ui,-apple-system,%22Segoe UI%22,Roboto,%22Helvetica Neue%22,%22Noto Sans%22,%22Liberation Sans%22,Arial,sans-serif,%22Apple Color Emoji%22,%22Segoe UI Emoji%22,%22Segoe UI Symbol%22,%22Noto Color Emoji%22; -webkit-user-select: none; -moz-user-select: none; user-select: none; text-anchor: middle;' width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E
|
||||
{{- if $show_title }}%3Ctitle%3E{{ $title }}%3C/title%3E{{ end -}}
|
||||
%3Crect width='100%25' height='100%25' fill='%23dee2e6'%3E%3C/rect%3E
|
||||
{{- if $show_text }}%3Ctext x='50%25' y='50%25' fill='%23868e96' dy='.3em'%3E{{ $text }}%3C/text%3E{{ end -}}
|
||||
%3C/svg%3E" />
|
||||
{{- else -}}
|
||||
<svg class="bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" width="{{ $width }}" height="{{ $height }}" xmlns="http://www.w3.org/2000/svg"{{ if (or $show_title $show_text) }} role="img" aria-label="{{ if $show_title }}{{ $title }}{{ if $show_text }}: {{ end }}{{ end }}{{ if ($show_text) }}{{ $text }}{{ end }}"{{ else }} aria-hidden="true"{{ end }} preserveAspectRatio="xMidYMid slice" focusable="false">
|
||||
{{- if $show_title }}<title>{{ $title }}</title>{{ end -}}
|
||||
<rect width="100%" height="100%" fill="{{ $background }}"/>
|
||||
{{- if $show_text }}<text x="50%" y="50%" fill="{{ $color }}" dy=".3em">{{ $text }}</text>{{ end -}}
|
||||
</svg>
|
||||
{{- end -}}
|
||||
|
Reference in New Issue
Block a user