How to make a fully responsive web page [closed]
Tags: html,css,responsive-design,media-queries
Problem :
I'm building a simple web page with two divs:
<body>
<div id="content"><img src="img/Apples.jpg"></div>
<div id="footer"><p>Some words!</p></div>
</body>
The "content" div has to be always above the "footer" div and the two divs have to be always displayed on each page size.
How can I do that?
Thanks!
Here is my CSS:
body {
padding: 18px;
}
#content {
/*width: 70%;*/
height: 70%;
display: block;
margin: auto;
}
#content img {
width: 100%;
height: auto;
}
#footer{
/*width: 30%;*/
height: 30%;
display: block;
margin: auto;
}
#footer p {
text-align: center;
margin-left: auto;
margin-right: auto;
}
UPDATE:
Here is my solution:
HTML:
<body>
<div id="content"></div>
<div id="footer"><p>Some words!</p></div>
</body>
Stylesheet:
body {
padding: 20px;
}
#content {
width: 100%;
background-image: url('img/Apples.jpg');
background-size: cover;
background-position: center;
height: 570px;
margin-bottom: 10px;
}
#footer{
height: 100%;
border-style: double;
border-color: black;
}
#footer p {
text-align: center;
margin-left: auto;
margin-right: auto;
}
/* Landscape phones and down */
@media (max-width: 340px) {
#content {
height: 370px;
}
}
/* Landscape phone to portrait tablet */
@media (min-width: 340px) and (max-width: 500px) {
#content {
height: 215px;
}
}
/* Landscape phone to portrait tablet */
@media (min-width: 501px) and (max-width: 767px) {
#content {
height: 660px;
}
}
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 801px){
#content {
height: 870px;
}
}
But I am not able to adjust the layout for each device. How can I do it?
Solution :
<body>
<div id="content" style="height:70%;display:block;"><img src="img/Apples.jpg"></div>
<div id="footer" style="height:30%;display:block;"><p>Some words!</p></div>
</body>
CSS Howto..
To achieve what you want: You need to change a couple of styles in your css. First: Add text-align: center; to your wrapper class. .wrapper { position:relative; width:90%; max-width:90%; margin:...
A couple of positioned pseudo-elements with a linear gradient background would be probably the simplest method. Note: Your menu HTML is invalid, ul can only have li as direct children..not...
Since mxmlc compiles only one css to swf at a time, we can merge or append multiple css files to single file and then compile that output css file to...
BIGGEST problem is that I DID NOT realize ORDER of codes does MATTER, BIG MATTER, no matter where you put those STYLE and SCRIPT in master or child page, they...
when you print the value add an attribute in the span element <span class='change' data-change='" + value.change + "'>" + value.change + "</span> thus use an attribute selector in CSS...
Add two additional properties to your .left li class: .left li { float: left; clear: left; } Updated jsfiddle...
applyIEFont = function() { var iev=0; var ieold = (/MSIE (\d+\.\d+);/.test(navigator.userAgent)); var trident = !!navigator.userAgent.match(/Trident\/7.0/); var rv=navigator.userAgent.indexOf("rv:11.0"); if (ieold) iev=new Number(RegExp.$1); if (navigator.appVersion.indexOf("MSIE 10") != -1) iev=10; if...
or use \25BC div:after { content: '\25BC'; } <div></div> ...
Maybe this: <UL> <LI CLASS="image"> <IMG SRC="..." /> </LI> <LI CLASS="image"> <IMG SRC="..." /> </LI> <LI CLASS="image"> <IMG SRC="..." /> </LI> </UL> With this CSS: .image { display: inline; }...
No one addressed the javascript aspect of this question. Below is a complete (albeit quick and dirty) web page that will draw 6 perfectly spaced circles around a parent circle's...
Sorry I kinda butchered your js and html a bit, but this should work HTML <div class="dropDownList"> <ul id="classDropDownList"> <li><a href="#" id="classMenuHeader">Select Class</a> <ul id="dropDownSelections"> <li onclick="classSelect('item1');"> <input type="button" value="item1"...
With CSS, there's a bunch of options. You could try hr { margin-botton: 0; } Or instead of using an hr, you could add some padding to the menu, and...
//assuming that you have only one li element var a_text = $('li > a').text(); var li_text = $('li').text().replace(a_text,''); $('li').html($('li').html().replace(li_text,'<span style="background:#000;color:#fff">'+li_text+'</span>')); for more then one element: //assuming more then one $('li').each(function(){...
If you change the display property to flex it fills the whole (height between header and footer) and adjusts when you resize. #page-layout { display: flex; } ...
If all you need is a very simple bounce, it's as easy as just changing the transition function from ease-in to something else, such as a cubic-bezier. An example of...
[This is a hack, but is works] If you can change your markup, then you can add a div after the input.form-control and simulate the parent styling to that div...
What about this? HTML structure: <ul> <li class="task"> <div class="line"> <span class="task-date">Date Created</span> <span class="task-title">Task Title</span> </div> <div class="line"> <span class="task-due-date overdue">Date Overdue</span> <span...
You can put a max-width on the li to make sure it doesn't go further that it's parent container. max-width: 100%; I'm not sure if this is what you mean...
A css file for each .aspx page seems to defeat its purpose, namely reusability, etc. I suppose if each page is really that unique from a style perspective, maybe it's...
Try adding the following to your style to prevent wrapping: white-space:nowrap; ...
Styling the #content div with position:absolute rather than position:fixed will solve your scrolling issues, but you will need to tweak other things. Absolute position pulls the content completely out of...
Just change height to max-height:75% instead of height:100%. #content { max-height: 75%; overflow: auto; text-align: center; width: 100%; } Hope it will help you....
you can not manipulate the DOM with CSS, you need JS or something similar. You will need to try something like this: $("#id-of-first-element").append( $("#id-of-last-element") ); $("#id-of-last-element").html(''); ...
table { width: 30%; } th, td { border-right: 1px solid #000; border-bottom: 1px solid #000; width: 20%; text-align: center; font-weight: bold; padding: 0px; } th{ background: #606060; border:...
I am not completely sure if i understand you correctly, but your heights (i.e. the heights within the #container div) add up to 15% + 100% + the height of...
I haven't used Awesomium, but it's probably best to remove the scrollbars in CSS. Even if the whole outer web control/page has no scrollbars, the page can have an element...
I think you haven't added any element inside the div. Place some text inside it or add height: 50px; in CSS
Nevermind just got it: .tinymce-editor *, .tinymce-editor *:before, .tinymce-editor *:after { -webkit-box-sizing: content-box !important; -moz-box-sizing: content-box !important; box-sizing: content-box !important; } ...
You can modify your script like this: $('#compositingWork').click(function(){ $(this).addClass('active'); $('#portfolioWork').load('portfolioContent.html #PortfolioCompositing'); }); and add this to css: .active { background: url("Images/Nav_Underline.png") repeat-x; background-position: center bottom; } upd. but the easier...
http://jsfiddle.net/bvgVK/2/ div { width: 100px; height: 100px; background: red; margin: 20px; -webkit-opacity: 0; -moz-opacity: 0; -ms-opacity: 0; -o-opacity: 0; opacity: 0; -webkit-transition: opacity 300ms; -moz-transition: opacity 300ms; -ms-transition: opacity 300ms;...