How to repeat an HTML CSS image

1

I want to use an image in the header of the site, it is small and I would like to repeat it horizontally throughout the header using CSS.

The HTML is as follows:

<body>
<header>
    <div id="cabecalho">
        <img src="pasta/imagem.jpg">
        <h1>Texto</h1>
        <h2>Texto</h2>
    </div>
</header>

Thanks in advance for the help.

    
asked by anonymous 26.04.2015 / 21:33

2 answers

4

You will not be able to repeat the image using background-repeat: repeat-x; because in fact there is no specified background. What you need is to upload the image you want through background-image:url(...) . Then yes you can give instructions to him. Example:

#cabecalho {
    background-image:url('http://placehold.it/30x30');
    background-repeat:repeat-x;
}
<header>
    <div id="cabecalho">
        <h1>Texto</h1>
        <h2>Texto</h2>
    </div>
</header>
    
26.04.2015 / 21:50
-1

Try to put:

#cabecalho {
    background-image:url('http://placehold.it/30x30');
    width: 100%;
    height: 150px;
}
    
15.10.2015 / 03:36