Question

I have a ruby on rails app, and I'd like to put a full width background-color to a div, but without success, everytime I have unwanted left-right and top margin.

Here is my code:

       <!DOCTYPE html>
<html lang="en">

<!-- header -->
<body>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">



<div class="homepage">
  <div class="container center">
    <div class="texthomepage1">
    <br>
    <font color="white"><p>Découvrez des startups</p></font>
    </div>
        <div class="texthomepage2">
        <p><font color="white">Faites les découvrir à vos amis & obtenez des récompenses.</font></p></font>
        </div>
        <br><br><br>
          <center>
           <!-- REGISTRATION FIELDS -->
           <div class="panel-body">
            <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
              <%= devise_error_messages! %>

            <div class="form-group">
            <%= link_to "Rejoindre Gratuitement", new_user_registration_path, class: "btn btn-lg btn-info" %>
            <% end %>
            <!-- /REGISTRATION FIELDS -->
            <br><br><br>
            </div>
            </div>
            </center>
  </div>
</div>

Here is my css for the .homepage div:

    .homepage {
    background-color: #e4685d;
    margin: 0 
}

But with that code I stil have a margin, so the background color doesn't cover the full background.

What could be the right way to do this ?

Was it helpful?

Solution

Make sure your body class doesn't have padding and margins

body{padding:0;margin:0;}
.homepage {
background-color: #e4685d;
margin: 0;
}

OTHER TIPS

Try:

body{
  margin:0;
}

Also, your <meta />, <style> or <link> tags should be inside a <head> tag. Notice that your <meta /> tag is in your <body>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top