I want to add a call support button to my webpage that has responsive design. I want to show the button only when the webpage is in mobile view and replace it with a line of text when it is not mobile view.
I'm having problems showing/hiding the button for the responsive webpage.
Here's my attempt:
contact page:
<div>
<p class ="Call-Customer-Support">Call customer support at 555-555-5555. </p>
<div class="Rectangle">
<img class="call icon-image" src="images/call.png" />
<a class="Call-Support" href="tel:555-555-5555">Call Support</a>
</div>
</div>
where in my style.css:
.Call-Customer-Support {
width: 709px;
height: 18px;
font-family: BentonSans-Bold;
font-size: 16px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin: 50px auto;
}
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
and in my responsive.css:
#media only screen and (max-width: 767px) {
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
}
#media only screen and (max-width: 479px) {
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
}
For all other sizes, I set these properties:
.Rectangle {visibility:hidden}
.call {visibility:hidden}
.Call-Support{visibility:hidden}
However, it has no effect on the visibility of the items displayed...
here I added basic implementation of what you try to achieve
.call-support {
display: inline-block;
padding: 5px 10px;
background: #aaa;
color: white;
font-family: Arial;
text-transform: uppercase;
text-decoration: none;
border-radius: 5px;
}
.support {
text-align: center;
}
.show-large {
display: none;
}
#media only screen and (min-width: 767px) {
.show-large {
display: block;
}
.show-mobile {
display: none;
}
}
<div class='support'>
<a class="call-support show-mobile" href="tel:555-555-5555">Call Support</a>
<span class='show-large'>Call customer support at 555-555-5555.</span>
</div>
visibility is not enough to hide an element. You need to specify display:none; for it to be trully hidden.
In you example you can change the display property of the button to block inside the responsive file and display:none for the text. In the main css file you need to do exactly the opposite.
Also you can remove all duplicate code between files as both, I pressume, are included in the site (for example width,height etc.).
So the responsive file can be recuced to this code:
#media only screen and (max-width: 767px) {
.Rectangle {
display:block;
}
.Call-Customer-Support {
display:none;
}
}
Related
I have a heading with a left side strip line; it's working fine in desktop but not looking fine in mobile view, in mobile strip line override the heading, how do I make this work in responsive (mobile) views?
.title {
font-size: 35px;
color: #000000;
font-family: "Open Sans"!important;
margin-bottom: 10px;
clear: both;
margin-left:50px;
}
.strip {
background-color: #ffc20e;
width: 87%;
position: absolute;
height: 31px;
border-radius: initial!important;
left: -1010px;
}
#media only screen and (max-width: 550px)
.strip {
left: -356px!important;
}
<h4 class="title"><span class="strip"></span>Heading</h4>
there is no need of any media query!
.title {
font-size: 35px;
color: #000000;
font-family: "Open Sans"!important;
margin-bottom: 10px;
clear: both;
}
.strip {
background-color: #ffc20e;
width: 110px;
display: inline-block;
height: 25px;
margin-right: 8px;
}
#media screen and (max-width: 767px){\
.title {
font-size: 18px;
}
.strip {
width: 50px;
}
}
<h4 class="title"><span class="strip"></span>Heading</h4>
I want to have a white background where the user can select a item in the autocomplete however I have my header image that keeps repeating.
Here is a image of my probleme
As you can see I highlighted in blue every suggestion. However I get the background image for each suggestion instead of having a simple white background.
Here is my html
<header>
<h1>
<a href="/">
<span class="texte-cache">Sel gras</span>
</a>
</h1>
<section class="section-recherche">
<?php
// define variables and set to empty values
$rechercheErr = "";
$recherche = "";
$rechercheValid = false;
?>
<form method="get" action="../pages/recherche.php">
<label for="recherche" class="lblRechercher">Rechercher</label>
<div class="recherche">
<input type="search" name="recherche" id="recherche" placeholder="Rechercher..." value="<?php echo $recherche; ?>" />
<span class="error"> <?php echo $rechercheErr; ?></span>
<button title="Rechercher" class="button-recherche" id="buttonRecherche" name="submit"><i class="material-icons-white">search</i></button>
</div>
<div id="div-suggestions" class="suggestions masquer"></div>
</form>
</section>
</header>
And here is my css that cause the probleme
/*Exemple when screen is large*/
#media screen and (min-width: 1300px) {
header a {
display: block;
margin-left: auto;
margin-right: auto;
height: 270px;
background-size: 100% 120%;
background-image: url(../images/logo-long.jpg);
background-repeat: no-repeat;
background-position: center top;
}
}
Here is the css for the autcomplete.
.afficher {
display:block;
}
.masquer {
display:none;
}
.suggestions {
background-color:white;
width:194px;
position:absolute;
border: 1px solid gray;
background-image: none;
}
.suggestions ul {
padding-left:0;
margin:0;
list-style-type:none;
}
.suggestions ul li:hover {
background-color:lightblue;
}
I have tried to add
background-image: none;
However it did not work. What can I do to fix this problem thank you for your help
I have added a JsFiddle here
https://jsfiddle.net/L9afb2u0/
the code is a little hard to understand, but basically, remove background image and add an img element on the html doc.
var scriptSug =
{
"divSuggestions" : null
};
function viderElement(element) {
while (element.lastChild) {
element.removeChild(element.lastChild);
}
}
/**
* Appelée lors d'un clic dans la fenêtre
*/
function gererClicFenetre(evenement) {
var clicDedans = scriptSug.divSuggestions.contains(evenement.target);
window.console.log("Clic dans la zone cliquable ? " + clicDedans);
if (!clicDedans) {
viderElement(scriptSug.divSuggestions);
scriptSug.divSuggestions.className = "suggestions masquer";
document.removeEventListener("click", gererClicFenetre);
}
}
/**
* Pour demander les suggestions au site web.
*
* On devrait procéder par AJAX pour récupérer les suggestions, mais
* elles sont "hard-codés" pour la démo.
*/
function afficherSuggestions() {
viderElement(scriptSug.divSuggestions);
scriptSug.divSuggestions.className = "suggestions afficher";
var elemListe = document.createElement("ul");
scriptSug.divSuggestions.appendChild(elemListe);
for (var i=0;i<5;i++) {
var itemListe = document.createElement("li");
// TODO : ne pas mettre de .innerHTML dans votre TP
itemListe.innerHTML =
"<a href='http://www.google.ca'>Suggestion " + i + "</a>";
elemListe.appendChild(itemListe);
}
// Ajout d'un événement sur tout le document (la fenêtre)
document.addEventListener("click", gererClicFenetre, false);
}
/**
* Appelée lors de l'initialisation de la page
*/
function initialisation() {
scriptSug.divSuggestions = document.getElementById("div-suggestions");
document.getElementById("recherche").addEventListener("input", afficherSuggestions, false);
}
window.addEventListener("load", initialisation, false);
#charset "UTF-8";
/* Créé par Junior Corenbach et MINH NGUYEN */
html,
body {
margin: 0;
}
#page{
background-color: #eFeFeF;
margin: auto;
width: 80%;
height: 100%;
font-family: Arial, Helvetica, sans-serif;
padding-bottom: 3%;
}
a{
text-decoration: none;
color: #aa0000;
}
a:hover{
text-decoration: none;
color: #DB9900;
}
p{
margin-left: 30px;
}
header{
background-color: #DFDFDF;
margin: auto;
width: auto;
}
main{
margin-left: 30px;
contain: layout;
}
footer{
margin-left: 30px;
padding-bottom: 30px;
}
/* || En tête */
h1{
margin: 0;
}
h2{
margin: 0;
text-align: center;
}
h4{
margin: 0;
font-size: 1.4rem;
text-align: center;
}
.afficher {
display:block;
}
.masquer {
display:none;
}
.suggestions {
background-color:white;
width:194px;
position:absolute;
border: 1px solid gray;
}
.suggestions ul {
padding-left:0;
margin:0;
list-style-type:none;
}
.suggestions ul li:hover {
background-color:lightblue;
}
/* || Page connection */
#connection div{
margin: 10px;
}
input[type=button], input[type=submit] {
background-color: #DB9900; /* Green */
border: #7F5900 solid 1px;
border-radius: 5px;
color: white;
padding: 5px 10px;
display: inline-block;
text-align: center;
text-decoration: none;
font-weight: bold;
font-size: 16px;
width: 50%;
}
input[type=button], input[type=submit]:hover {
background-color: #C08600;
cursor: pointer;
}
input[type=button], input[type=submit]:active {
background-color: #A57300;
}
.error{
color: red;
}
.recherche{
display: flex;
margin-bottom: 3%;
}
.gallery-link{
color: #111;
}
.gallery-link:hover{
color: #DB9900;
}
/*min ici pour tout ecran plus grand est une image*/
#media screen and (min-width: 1300px) {
header a {
display: block;
margin-left: auto;
margin-right: auto;
height: 270px;
}
}
#media screen and (max-width: 1300px) {
header a {
display: block;
margin-left: auto;
margin-right: auto;
height: 270px;
background-size: 100% 120%;
}
}
#media screen and (max-width: 1000px) {
header a {
display: block;
margin-left: auto;
margin-right: auto;
height: 270px;
}
}
#media screen and (max-width: 700px) {
header a {
display: block;
margin-left: auto;
margin-right: auto;
height: 270px;
}
}
.texte-cache {
position: absolute !important;
clip: rect(1px, 1px, 1px, 1px) !important;
clip: rect(1px, 1px, 1px, 1px) !important;
}
/******************************************/
/*************** MENU***********************/
/******************************************/
.menu-principal {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #DB9900;
}
.menu-principal li {
float: left;
}
.menu-principal li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.menu-principal li a:hover {
background-color: #111;
}
/******************************************/
/***********ERREUR*************************/
/******************************************/
.imag-erreur{
width: 100%;
}
.header-erreur{
text-align: center;
font-size: 1000%;
color:#DB9900;
border: #111111;
}
.erreur-text-large{
font-size: 300%;
text-align: center;
margin: 0;
}
.erreur-text-petit{
font-size: 120%;
text-align: center;
color:#111;
margin: 0;
}
.icon-page-acces{
text-align: center;
}
/******************************************/
/***********GALERY*************************/
/******************************************/
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
}
.material-icons-yellow {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
color: #DB9900;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
}
.material-icons-yellow-large {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
color: #DB9900;
font-size: 900%;
line-height: 1;
letter-spacing: normal;
text-transform: none;
vertical-align: top;
}
.material-icons-white {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
color: white;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
}
.material-icons-white-small {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
color: white;
font-size: 16px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
}
.material-icons-red {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
color: #aa0000;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
}
div#gallery-large {
margin: 5px;
border: 1px solid #ccc;
display: inline-block;
width: 70%;
background-color: white;
text-align: center;
}
#gallery-auto{
display: inline-block;
text-align: center;
width: 95%;
}
.titre-gallery-auto-section{
min-height: 50px;
}
.gallery-hiden{
display: none;
clip: rect(1px, 1px, 1px, 1px) !important;
clip: rect(1px, 1px, 1px, 1px) !important;
}
div.gallery {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
background-color: white;
}
div.gallery:hover {
border: 1px solid #777;
}
.imageRecette {
width: 100%;
height: auto;
}
div.desc {
text-align: center;
}
div.desc p{
float: right;
margin: 0;
padding: 0px;
text-align: center;
}
.list-recettes{
display: flex;
flex-wrap: wrap;
float: left;
}
.titre-gallery{
min-height: 150px;
}
/******************************************/
/******************************************/
/******************************************/
.image-details-recette{
float: right;
margin: 5px;
width: 30%;
overflow: auto;
}
.deuxieme-section-recette{
padding-top: 2%;
clear: both;
}
input[type=text], input[type=password], input[type=email] {
width: 100%;
padding: 12px 10px;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
input[type=search] {
width: 60%;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
.section-recherche{
position: absolute;
top: 190px;
padding-left: 20px;
width: 80%;
}
input[type="checkbox"]{
padding: 0%;
cursor: pointer;
}
input[type="submit"]{
width: 100%;
padding: 12px 10px;
}
hr{
margin: 1%;
}
#buttonRecherche{
width: 50px;
border-radius: 0px;
border: none;
}
#button-commenter{
width: 120px;
display: block;
margin-top: 1%;
margin-bottom: 1%;
}
#button-gallery-precedent{
width: 120px;
margin-top: 1%;
margin-bottom: 1%;
display: none;
}
#button-gallery-suivant{
width: 120px;
margin-top: 1%;
margin-bottom: 1%;
display: none;
}
.btn-gallery{
text-align:center;
}
.image-gallery-auto{
width: 100%;
height: 100%;
}
textarea{
width: 99%;
resize: none;
}
.section-commentaire{
margin-left: 2%;
}
.pied li{
list-style-type: none;
}
.pied-couriel li{
list-style-type: none;
}
button{
background-color: #DB9900;
border: #7F5900 solid 1px;
border-radius: 5px;
color: white;
padding: 5px 10px;
display: inline-block;
text-align: center;
text-decoration: none;
font-weight: bold;
font-size: 16px;
width: 50%;
}
.lblRechercher{
display: inline;
color:white;
font-size: 100%;
}
a{
background: white;
border: 5px solid reD;
}
<html>
<body style="">
<div id="page">
<header>
<h1>
<a href="/">
<img src="https://static.makeuseof.com/wp-content/uploads/2008/05/opensource.gif" />
<span class="texte-cache">Sel gras</span>
</a>
</h1>
<section class="section-recherche">
<form method="get" action="../pages/recherche.php">
<label for="recherche" class="lblRechercher">Rechercher</label>
<div class="recherche">
<input type="search" name="recherche" id="recherche" placeholder="Rechercher..." value="" />
<span class="error"> </span>
<button title="Rechercher" class="button-recherche" id="buttonRecherche" name="submit"><i class="material-icons-white">search</i></button>
</div>
<div id="div-suggestions" class="suggestions masquer"></div>
</form>
</section>
</header>
</div>
</body>
</html>
You can add a <span class="YourClass">Suggestion 0</span> inside the a href and give a different css to the span then you can modify only the suggestions 0 etc
I figured it out I used
#media screen and (min-width: 1300px) {
header h1 a {
instead of
#media screen and (min-width: 1300px) {
header a {
You should learn a bit more for how css selectors works.
Since header a says, any a in header should have next styles (and you dropdawn is part of header and has a in it) it inherits that styles.
To be more specific you could add some class for yours a in header (a.link for example), and separate styles in that way.
I have a media query to change the look of a footer when the site goes mobile, but, for some reason, it doesn't seem to want to take the media query styles over the original base style. The specific CSS code is as follows
.footy {
background-repeat: no-repeat;
background-image: url('../Images/LandingBottomRightCorner_FullSpan.png');
background-position-x: right;
min-height: 338px;
position: relative;
left: 0;
bottom: 0;
width: 100%;
overflow: hidden;
}
.footytext {
position: absolute;
bottom: 0;
right: 0;
text-align: center;
margin: 13px;
}
.footytextelement {
color: white;
font-size: 18pt;
font-family: Arial;
font-weight: bold;
}
.joinnow {
border: 3px solid white;
border-radius: 12px;
font-style: italic;
margin: 10px;
}
.footytext a:hover {
text-decoration: none;
}
#media (max-width: 1279px) {
/*FOOTER APPEARANCE MOBILE*/
.footy {
background-repeat: repeat-x;
background-image: url('../Images/MBLLandingFooterGradient_ForRepeat.png');
height: 338px;
position: relative;
width: 100%;
overflow: hidden;
}
.footytext {
position: center;
text-align: center;
margin: 13px;
}
.footytextelement {
color: white;
font-size: 16pt;
font-family: Arial;
font-weight: bold;
}
.joinnow {
border: 3px solid white;
border-radius: 12px;
font-style: italic;
margin: 10px;
}
.footytext a:hover {
text-decoration: none;
}
}
The HTML being manipulated is:
<div class="footy">
<div class="footytext">
<div class="footytextelement">Make a plan.</div>
<div class="footytextelement">Get medications.</div>
<div class="footytextelement">Quit.</div>
<div class="footytextelement joinnow">Join Now!</div>
</div>
</div>
.footy {
background-color:red;
background-position-x: right;
min-height: 338px;
position: relative;
left: 0;
bottom: 0;
width: 100%;
overflow: hidden;
}
.footytext {
position: absolute;
bottom: 0;
right: 0;
text-align: center;
margin: 13px;
}
.footytextelement {
color: white;
font-size: 18pt;
font-family: Arial;
font-weight: bold;
}
.joinnow {
border: 3px solid white;
border-radius: 12px;
font-style: italic;
margin: 10px;
}
.footytext a:hover {
text-decoration: none;
}
#media (max-width: 1279px) {
/*FOOTER APPEARANCE MOBILE*/
.footy {
background-color:green;
background-position-x: right;
background-position-y:bottom;
height: 338px;
position: relative;
left: 0;
bottom: 0;
width: 100%;
overflow: hidden;
}
.footytext {
position: center;
bottom: 0;
right: 0;
text-align: center;
margin: 13px;
}
.footytextelement {
color: white;
font-size: 18pt;
font-family: Arial;
font-weight: bold;
}
.joinnow {
border: 3px solid white;
border-radius: 12px;
font-style: italic;
margin: 10px;
}
.footytext a:hover {
text-decoration: none;
}
}
<div class="footy">
<div class="footytext">
<div class="footytextelement">Make a plan.</div>
<div class="footytextelement">Get medications.</div>
<div class="footytextelement">Quit.</div>
</div>
</div>
Your max-width in media query should be 768px as standard.
You have given 1279px which means no matter whether you are in mobile device or desktop, media query css will apply everywhere.
With that media's condition you are saying: apply these styles above 1279px.
Use min-width and max-width to get more control.
example:
#media (max-width: 719px) {...}
#media (max-width: 1023px) {...}
More information: MDN LINK
I have used many suggested methods to ensure my footer stays at the bottom and it does however when i re-size the window to make it smaller the footer does not get pushed off the page due to the position: fixed; i am using but otherwise it does not stay at at the bottom of the page at normal size as the content does not fill the whole page.
Can you help?
EDIT:
CSS
html, body {
margin:0;
padding:0;
height: 100%;
}
#container {
}
#spacer {
height: 10px;
background-color: #24246B;
}
#font-face {
font-family: palatino;
src: url('font/palatino.ttf');
}
#font-face {
font-family: footer;
src: url('font/footer.ttf');
}
.fb_widget {
float: right;
margin-right: 10px;
}
#header, #nav, article, section, body, #mail_success {
font-family: palatino;
}
#header {
margin-top: 1%;
text-align: center;
/* font-size: 60px;
color: #F2E6FF;
border: solid #24246B;
background-color: #24246B;
width: 25.5%;
border-right-color: #4610B3;
border-right-width: 25px;
border-left-width: 15px;
margin-top: 2%;
text-align: right;*/
}
#nav ul {
margin-top: 2%;
line-height: 30px;
font-size: 17px;
text-align: center;
background-color: #24246B;
}
#nav ul li {
display: inline;
}
#nav ul li a {
text-decoration: none;
color: #F2E6FF;
padding: 7px 2% 6px 2%;
font-weight: bold;
border-radius: 20%;
/* This makes it fade colour*/
-o-transition: .5s;
-ms-transition: .5s;
-moz-transition:. 5s;
-webkit-transition: .5s;
transition: .5s;
}
#nav a:hover {
color: #24246B;
background-color: #F2E6FF;
border-radius: 20%;
}
body {
background-image: url('media/bg.png');
padding-bottom: 60px;
height: 100%;
max-height: 100%;
}
article {
color: #24246B;
margin-left: 20%;
margin-right: 20%;
font-size: 20px;
font-weight: bold;
}
section {
font-weight: normal;
font-size: 15px;
text-align: justify;
padding-left: 2%;
}
form {
padding-left: 7%;
font-size: 19px;
}
input {
height: 25px;
width: 300px;
font-size: 14px;
}
.contact_submit {
width: 110px;
margin-right: 50%;
margin-left: 42%;
}
label {
text-align: right;
float: left;
display: block;
width: 260px;
font-weight: bold;
}
label:after {
content: "..";
color: transparent;
}
#push {
height: 4em;
}
footer {
font-family: footer;
color: #cccccc;
font-size: 8px;
text-transform: uppercase;
font-style: italic;
text-align: center;
height: 4em;
}
footer:hover {
/* This makes it transition*/
-o-transition: .5s;
-ms-transition: .5s;
-moz-transition:. 5s;
-webkit-transition: .5s;
transition: .5s;
color: #24246B;
font-size: 12px;
}
#mail_success {
text-align: center;
padding: 7%;
font-size: 17px;
font-weight: bold;
}
#media screen and (max-device-width: 640px) {
#logo {
display: none;
}
}
HTML
<div id="push"></div>
</div>
<p></p>
<footer>
<p>©2013 Built by Rob **</p>
<p>Designed by Akash ** & Rob **</p>
</footer>
</body>
Here is your solution.Use sticky footer.Include the below css file in your code
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
Hope it will help you.
Also here is a link for more details
Link
You did not paste in your code or give us a jsfiddle, so here is what I think you should do.
In your css, use media queries and change how the footer appears based on the screen width.
Portrait Tablet
#media (min-width: 481px) and (max-width: 768px)
Landscape smart phone
#media (min-width: 321px) and (max-width: 480px)
Portrait smart phone
#media (max-width: 320px)
Using those, set:
#footer{
position:whatever you want;
}
FYI, you're not constrained to those sizes, those are just the common ones, customize them how you want.
I'm trying to get my background image to show at the top center of the page. The image works fine if I do:
<style>
body {
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed;
}
</style>
I can't seem to work out where I've gone wrong. There must be something I've managed to mess up, I just can't see it. Here is the CSS:
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('img/top_logo_blank_small.png') no-repeat fixed;
color: #fff;
margin: 0;
padding: 0;
}
a {
color: black;
text-decoration: none;
}
/* Typography */
.header h1 {
position: absolute;
width:100%;
top: 50%;
margin-top: -20px;
text-align: center;
letter-spacing: 4px;
}
.header h1 em {
font-size: 1.200em;
font-style: normal;
}
h1 {
font-size: 2.2em;
color: #fff;
}
.content h2 {
font-size: 1.75em;
color: #fff;
letter-spacing: 4px;
text-align: center;
}
.content h2 em {
font-size: 1.2em;
font-style: normal;
}
.content h3 {
text-align: center;
font-size: 1.0em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
margin-bottom: 25px;
}
.content h4 {
margin-top: 0;
text-align: center;
font-size: 0.8em;
font-weight: normal;
color: #ede0ed;
letter-spacing: 1px;
}
#banner p {
text-align: center;
}
/* Navigation */
#nav {
margin: 4px 4px 40px;
}
#nav ul {
padding: 0;
margin: auto;
list-style: none;
}
#nav ul li {
width: 50%;
color: #BBB;
float: left;
font-family: 'Cabin Sketch';
font-size: 1.75em;
text-align: center;
background: url(img/scribble_dark.png);
}
#nav ul li a {
display: block;
/*padding: 5px 20px;*/
}
#nav ul li a:hover {
background: #e0d0e0;
}
/* Content */
.container{
max-width: 720px;
margin: 50px auto 0;
background: #FFF url('img/top_logo_blank_small.png') no-repeat fixed 0 0;
}
.header {
position: relative;
background-color: #b88fb8;
border-top: 5px solid #ede0ed;
height: 75px;
}
.content {
background-color: #000;
padding: 15px;
margin-bottom: 10px;
}
div#about {
padding:25px;
min-height: 255px;
}
img#portrait {
float: left;
margin-right: 25px;
width: 256px;
height: 256px;
}
div#footer {
width: 100%;
max-width: 720px;
margin: auto;
color: black;
text-align: right;
padding: 0 10px;
font-size: 0.850em;
}
#media screen and (max-width: 650px) {
.container {
width: 90%;
max-width: none;
}
div#footer {
width: 90%;
}
}
Try to change your path for example:
background: #EEE url('../img/top_logo_blank_small.png') no-repeat fixed top;
Because you are in a subfolder, you have to go up of a level I think
Most likely your css file is in a different folder and therefore needs another path to the image file.
The common way is to put css in a separate css/* folder, so the path should be:
url('../img/top_logo_blank_small.png')
This CSS seems to work fine, are you certain that the image exists?
http://jsfiddle.net/ghsNR/
I've just tried it here and it works fine with an image from http://placehold.it/
body {
font-family: 'Quattrocento Sans', helvetica, sans-serif;
background: #EEE url('http://placehold.it/500x500') no-repeat fixed top;
color: white;
margin: 0px;
padding: 0px;
}
The most likely cause after observing this is that your CSS isn't actually locating your image correctly. I suggest using tools like the Chrome dev tools, or Firebug to inspect the absolute path that the browser is trying to use to load the image and moving forward from there.
Is the css in the same folder as the page? If you have a different folders, you need to change the URL accordingly.
Maybe change the URL to
'../img/top_logo_blank_small.png'