• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Need background image to "scale to fit" and "tile vertically"

New Here ,
Jun 10, 2018 Jun 10, 2018

Copy link to clipboard

Copied

I am creating a web site with a background image that I need to scale to fit the browser width (responsively) and also tile vertically.  However when I choose tile vertically from the drop down the image is enlarged and looks horrible.  How can I have the background image do both?

Views

445

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 10, 2018 Jun 10, 2018

CSS does not allow scaled backgrounds to repeat.   Either your background image scales to fill the viewport in both directions or it does not scale.  

Example 1 -- Background-size: cover

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Full Size Background</title>

<style>

body {

    background: #000 url(https://placeimg.com/900/600/arch);

    background-size: cover;

}

.container {

    background: rgba(0,0,0,0.5);

    color: #FFF;

    width: 50%;

    margin: 0 auto;

    padding: 3%;

}

</style>

</head>

<bo

...

Votes

Translate

Translate
Community Expert ,
Jun 10, 2018 Jun 10, 2018

Copy link to clipboard

Copied

CSS does not allow scaled backgrounds to repeat.   Either your background image scales to fill the viewport in both directions or it does not scale.  

Example 1 -- Background-size: cover

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Full Size Background</title>

<style>

body {

    background: #000 url(https://placeimg.com/900/600/arch);

    background-size: cover;

}

.container {

    background: rgba(0,0,0,0.5);

    color: #FFF;

    width: 50%;

    margin: 0 auto;

    padding: 3%;

}

</style>

</head>

<body>

<div class="container">

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa quibusdam sunt, nisi voluptas, labore, impedit enim quo consequuntur nesciunt illum earum commodi quod inventore harum fugiat, error distinctio vitae vero.</p>

</div>

</body>

</html>

Example 2 - Background-repeat: y

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Tiled Background</title>

<style>

body {

    background: #000 url(https://placeimg.com/900/600/arch) center center repeat-y; 

}

.container {

    background: rgba(0,0,0,0.5);

    color: #FFF;

    width: 50%;

    margin: 0 auto;

    padding: 3%;

}

</style>

</head>

<body>

<div class="container">

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsa quibusdam sunt, nisi voluptas, labore, impedit enim quo consequuntur nesciunt illum earum commodi quod inventore harum fugiat, error distinctio vitae vero.</p>

</div>

</body>

</html>

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2018 Jun 10, 2018

Copy link to clipboard

Copied

Ok that is what I was thinking..  I can scale the image in PS to be the right width.  This should then tile okay, but what happens when the width of the browser goes smaller than the image?  For example if the default width is 2000 px, what would the image to at 1500 px?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2018 Jun 10, 2018

Copy link to clipboard

Copied

Try it and see what happens .

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 10, 2018 Jun 10, 2018

Copy link to clipboard

Copied

LATEST

if the design is in a breakpoint Muse will crop the image (jpeg by default) and use that... this is why a gif buggers up if its not set to non-resize

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines