Background

Background Position

Can I use ?Can I use ?
classproperties
background-position:value / bg:valuebackground-position: value
background-position:x|ybackground-position: x y
background-position:direction|direction|valuebackground-position: direction direction value
background-position:direction|value|direction|valuebackground-position: direction value direction value
background-position:position,background-position: position,
bg:topbackground-position: top
bg:bottombackground-position: bottom
bg:rightbackground-position: right
bg:leftbackground-position: left
bg:centerbackground-position: center

Overview

The background-position CSS property sets the initial position for each background image. The position is relative to the position layer set by background-origin.

<div class="">
background:top|left
bg:top
background-position:top|right
bg:left
bg:center
bg:right
background:bottom|left
bg:bottom
background:bottom|right
<div class="p:20!">
    <div class="grid-cols:3! gap:1 min-w:640 min-h:426">
        <div class="flex flex:col w:full align-items:center">
            <div class="background:top|left position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">background:top|left</code>
                    <code class="...">background-position:0%|0%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="bg:top position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">bg:top</code>
                    <code class="...">background-position:50%|0%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="background-position:top|right position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">background-position:top|right</code>
                    <code class="...">background-position:100%|0%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="bg:left position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">bg:left</code>
                    <code class="...">background-position:0%|50%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="bg:center position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">bg:center</code>
                    <code class="...">background-position:50%|50%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="bg:right position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">bg:right</code>
                    <code class="...">background-position:100%|50%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="background:bottom|left position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">background:bottom|left</code>
                    <code class="...">background-position:0%|100%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="bg:bottom position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">bg:bottom</code>
                    <code class="...">background-position:50%|100%</code>
                </div>
            </div>
        </div>
        <div class="flex flex:col w:full align-items:center">
            <div class="background:bottom|right position:relative w:full aspect:640/426 bg:url('/images/mountain.jpg') bg:no-repeat ...">
                <div class="...">
                    <code class="...">background:bottom|right</code>
                    <code class="...">background-position:100%|100%</code>
                </div>
            </div>
        </div>
        
    </div>
</div>

Applying with functions

<div class="background-position:$(value)">...</div>

Master supports native CSS variables and functions, just add var(--key) or use shorthand$(key) for variables.

You can also use calc(expression), env(expression) and other CSS functions if the property supports it.

To learn more, see the Functions documentation.

Conditionally apply

States and selectors

<div class="background-position:top:hover">...</div>

Master supports all native CSS selectors, just add :hover, :disabled, chaining, combinators and other CSS selectors as usual.

To learn more, see the Selectors documentation.

Responsive breakpoints

<div class="background-position:top@sm">...</div>

Responsive breakpoints can be applied to all styles. Some available breakpoints are 3xs, 2xs, xs, sm,md, lg, xl, 2xl, 3xl, 4xl. Arbitrary breakpoints can be specified through comparison operators >, >=, <, <=.

To learn more, see the Breakpoints documentation.

<div class="background-position:top@print">...</div>

Master supports media types like print, screen, speech, all, and other media queries.

To learn more, see the Media Queries documentation.

Dark mode and color schemes

<div class="background-position:top@dark">...</div>

Master uses the selector html.dark to support color schemes. Now, you can easily fine-tune your style for the color schemes.

To learn more, see the Color Schemes documentation.



© Aoyue Design LLC.
關於此頁的問題
編輯自AronLola