I'm trying to align y text to a project, but whenever I do, the text aligns to the viewport. Whenever I try aligning the text, the text moves with the viewport vertically.
header {
height: 900px;
background-image: url('../img/large-banner-image.png');
background-repeat: no-repeat;
background-position: center top;
}
span {
font: 60px Pacifico, sans-serif;
font-weight: 400;
}
.Header-Type {
vertical-align: -16px
}
img {
display: inline-block;
margin: 17px;
}
h1 {
text-align: center;
position: relative;
top: 62px;
right: 13px;
}
h2 {
font: 22px Raleway, sans-serif;
font-weight: 700;
}
p {
font: 36px Raleway, sans-serif;
font-weight: 300;
text-align: center;
position: relative;
top: 90px;
}
.Phone {
text-align: center;
position: relative;
top: -567px;
}
.Down-Arrow {
text-align: center;
position: relative;
top: -574px;
}
<.content-alt {
float: left;
margin: -600px 1800px
}
> .content-alt2 {
display: none
}
.content {
display: none
}
.content2 {
display: none
}
.alternate {
display: none
}
.other {
text-align: center;
}
.near-bottom {
text-align: center;
}
footer {
word-spacing: 30px;
}
.footer {
font: 16px HelveticaNeue, sans-serif;
font-weight: 400;
}
.Image {
text-align: center;
}
<header>
<h1> <img style="vertical-align:middle" src="img/focus.png"/><span>Focus</span></h1>
<p>A landing page for your app with focus</p>
</header>
<div class="Phone">
<img src="img/iphone.png" />
</div>
<div class="content-alt">
<h2>Great Feature</h2>
<div>Lorem ipsum dolor sit amet, consectetur
<br> adipiscing elit. Mauris interdum velit vitae
<br> nulla molestie eu. </div>
</div>
<div class="content">
<h2>Great Feature</h2>
<div>Lorem ipsum dolor sit amet, consectetur
<br> adipiscing elit. Mauris interdum velit vitae
<br> nulla molestie eu. </div>
</div>
<div class="content-alt">
<h2>Another Great Feature</h2>
<div>Lorem ipsum dolor sit amet, consectetur
<br> adipiscing elit. Mauris interdum velit vitae
<br> nulla molestie eu. </div>
</div>
<div class="content">
<h2>Another Great Feature</h2>
<div>Lorem ipsum dolor sit amet, consectetur
<br> adipiscing elit. Mauris interdum velit vitae
<br> nulla molestie eu. </div>
</div>
<div class="alternate">
<h2>Get The App Today!</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse fringilla fringilla nisl congue congue. Maecenas nec condimentum libero, at elementum mauris. Phasellus eget nisi dapibus, ultricies nisl at, hendrerit risusuis ornare luctus id
sollicitudin ante lobortis at.</div>
</div>
<div class="other">
<h3>“Focus is an app that is extremely useful. I would reccomend it to anyone.”</h3>
<div>Kyle Turner, Blogger</div>
</div>
<div class="Image">
<img src="img/people.png" />
</div>
<div class="near-bottom">
<h4>Say Hi & Get in Touch</h4>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit suspendisse.</div>
</div>
<footer>
<p>Contact Download Press Email Support</p>
</footer>
Any troubleshooting would be appreciated.
That's because you have the paragraph element set to position: relative. In this case, relative to the viewport. Get rid of that. You shouldn't be using relative positioning unless y absolutely required.
If you are trying to set the text to "vertical-align: middle" you should give it the display property: "display:table-cell" and its parent element the display property: "display:inline-table". That way your vertical align property will work without problems.
Here is a working example with floating elements for responsiveness on the page, hope that helps!
header{
height:250px;
background-image:url('../img/large-banner-image.png');
background-repeat: no-repeat;
background-position: center top;
}
span {
font: 60px Pacifico, sans-serif;
font-weight: 400;
}
.Header-Type{
vertical-align: -16px
}
img {
display: inline-block;
margin: 17px;
}
h1 {
text-align: center;
margin-top:60px;
}
h2 {
font: 22px Raleway, sans-serif;
font-weight: 700;
}
p {
font: 36px Raleway, sans-serif;
font-weight: 300;
text-align: center;
}
.content-alt {
text-align:left;
float:left;
width:20%;
margin-left:20%;
}
.content-alt2 {
text-align:left;
float:left;
width:20%;
margin-left:20%;
margin-top:60px;
}
.content-alt2::before{
clear:both;
}
.content {
text-align:left;
float:left;
width:20%;
margin-left:20%;
}
.content2 {
text-align:left;
float:left;
width:20%;
margin-left:20%;
margin-top:60px;
}
Related
I am a beginner front-end developer. I am currently creating a page consisting of subpages. The home page has:
At the very top of the menu
At the very bottom Footer
Title and text in the middle
The problem is that the title and text take up too little space on the page, so the Footer is not at the bottom, but right below this text. I would like the title and text to be right in the middle of the screen.
I tried using display: flex (text-align: center, justify-content: center), width, height, margin, padding, vw, position: relative/absolute etc. I have no idea how to do it. After all, I can't type in the padding, e.g. 10rem, because it will be unnatural.
const Main: React.FC = () => {
return (
<div className={styles.section}>
<div className={styles.position}>
<div className={styles.main}>
<div className={styles.title}>
<h1>
Lorem ipsum dolor sit amet
</h1>
</div>
<div className={styles.text}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vivamus convallis, diam vel faucibus
volutpat, eros arcu luctus arcu, in porta
dui quam quis leo.
</div>
</div>
</div>
</div>
);
};
export default Main;
.section {
padding: 2rem 0;
display: flex;
align-items: center;
justify-content: center;
}
.position {
width: 60%;
align-items: center;
justify-content: center;
}
.main {
text-align: center;
}
.title {
font-size: 3.5rem;
padding-bottom: 2.2rem;
font-weight: 700;
}
.text {
font-size: 1.2rem;
line-height: 1.9rem;
padding-bottom: 2.3rem;
font-weight: 400;
}
Please help me what to do so that the whole thing is centered on the whole screen and the footer is at the bottom of the screen. :(
.section {
padding: 2rem 0;
display: flex;
align-items: center;
justify-content: center;
}
.position {
width: 60%;
align-items: center;
justify-content: center;
}
.main {
text-align: center;
}
.title {
font-size: 3.5rem;
padding-bottom: 2.2rem;
font-weight: 700;
}
.text {
font-size: 1.2rem;
line-height: 1.9rem;
padding-bottom: 2.3rem;
font-weight: 400;
}
<div class="section">
<div class="position">
<div class="styles.main">
<div class="title">
<h1>
Lorem ipsum dolor sit amet
</h1>
</div>
<div class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus convallis, diam vel faucibus volutpat, eros arcu luctus arcu, in porta dui quam quis leo.
</div>
</div>
</div>
</div>
Hi how can I make the side menu to grow with the content of the parallel container, that should expand with its content as well.
I am trying to ensure that the left column enclosed in aside tag, is the same size as the content on the right enclosed in div column .right_panel. I was able to accomplish this by setting the size of html and body tag as well as .wrapper class to height: 100% as per similar queries on stackoverflow.
However now the .wrapper is not expanding when I add more content to main. I tried to change height to min-height but it shrink the aside to its content size.
I know I can accomplish this with flex layout but because flex is outside the scope of my course and also because I want to learn alternative approaches in case I would need to use them in the future for compatibility with the older browsers I am looking for solution that would not use flex layout.
Snippet below and JSFiddle link:
html,
body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
background-color: blue;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.wrapper {
margin: 10px auto 30px;
padding: 0;
width: 80%;
background-color: white;
height: calc(100% - 40px);
max-height: 100%;
}
aside.left_panel {
float: left;
min-height: 100%;
width: 130px;
background-color: #9eb9f1;
padding-left: 30px;
overflow: auto;
}
.right_panel {
margin-left: 160px;
}
nav ul {
list-style-type: none;
padding: 0;
}
header {
background-color: #6f90d1;
padding: 20px;
}
header h1 {
font-size: 60px;
color: darkblue;
}
main {
padding: 20px 20px 0;
}
main h2 {
color: #6f90d1;
}
main #lantern {
height: 400px;
width: 200px;
}
main img {
margin: 10px;
}
main h2{
margin-bottom: 30px;
}
main p {
margin-bottom: 30px;
}
footer {
text-align: center;
margin: 10px 0;
}
.f-right {
float: right;
overflow: auto;
}
.f-left {
float: left;
overflow: auto;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="styles/styles.css">
</head>
<body>
<div class="wrapper">
<aside class="left_panel">
<nav>
<ul>
<li>Home</li>
<li>Manu item 1</li>
<li>Manu item 2</li>
<li>Manu item 3</li>
</ul>
</nav>
</aside>
<div class="right_panel">
<header>
<h1>Name of the website</h1>
</header>
<main>
<img id="lantern" class="f-right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/PlaceholderLC.png/600px-PlaceholderLC.png" alt="">
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. </p>
<h2>Subheading 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius.</p>
</main>
<footer>
<p>Copyright © 2019</p>
</footer>
</div>
</div>
</body>
</html>
Using Table Layout
One solution is to use a table layout using display: table on the wrapper and making your left-section and right-section into a table-cell - see demo below:
html,body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
background-color: blue;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.wrapper {
margin: 10px auto 30px;
padding: 0;
width: 80%;
background-color: white;
height: calc(100% - 40px);
max-height: 100%;
display: table; /* added */
}
aside.left_panel {
/* float: left; */
min-height: 100%;
width: 130px;
background-color: #9eb9f1;
padding-left: 30px;
overflow: auto;
display: table-cell; /* added */
vertical-align: top; /* added */
}
.right_panel {
/*margin-left: 160px;*/
display: table-cell; /* added */
}
nav ul {
list-style-type: none;
padding: 0;
}
header {
background-color: #6f90d1;
padding: 20px;
}
header h1 {
font-size: 60px;
color: darkblue;
}
main {
padding: 20px 20px 0;
}
main h2 {
color: #6f90d1;
}
main #lantern {
height: 400px;
width: 200px;
}
main img {
margin: 10px;
}
main h2 {
margin-bottom: 30px;
}
main p {
margin-bottom: 30px;
}
footer {
text-align: center;
margin: 10px 0;
}
.f-right {
float: right;
overflow: auto;
}
.f-left {
float: left;
overflow: auto;
}
<div class="wrapper">
<aside class="left_panel">
<nav>
<ul>
<li>Home</li>
<li>Manu item 1</li>
<li>Manu item 2</li>
<li>Manu item 3</li>
</ul>
</nav>
</aside>
<div class="right_panel">
<header>
<h1>Name of the website</h1>
</header>
<main>
<img id="lantern" class="f-right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/PlaceholderLC.png/600px-PlaceholderLC.png" alt="">
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. </p>
<h2>Subheading 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius.</p>
</main>
<footer>
<p>Copyright © 2019</p>
</footer>
</div>
</div>
Using Float
You can try this - but you don't get the overflow right or won't be able to make the height of the columns the same - see an example to fiddle with that:
html,body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
background-color: blue;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.wrapper {
margin: 10px auto 30px;
padding: 0;
width: 80%;
background-color: white;
height: calc(100% - 40px);
max-height: 100%;
overflow: hidden; /* to clear the float */
}
aside.left_panel {
float: left;
min-height: 100%;
width: 130px;
background-color: #9eb9f1;
padding-left: 30px;
overflow-y: auto; /*changed to overflow-y */
}
.right_panel {
float: left; /* added */
width: calc(100% - 160px); /* added */
/*margin-left: 160px;*/
}
nav ul {
list-style-type: none;
padding: 0;
}
header {
background-color: #6f90d1;
padding: 20px;
}
header h1 {
font-size: 60px;
color: darkblue;
}
main {
padding: 20px 20px 0;
}
main h2 {
color: #6f90d1;
}
main #lantern {
height: 400px;
width: 200px;
}
main img {
margin: 10px;
}
main h2 {
margin-bottom: 30px;
}
main p {
margin-bottom: 30px;
}
footer {
text-align: center;
margin: 10px 0;
}
.f-right {
float: right;
overflow: auto;
}
.f-left {
float: left;
overflow: auto;
}
<div class="wrapper">
<aside class="left_panel">
<nav>
<ul>
<li>Home</li>
<li>Manu item 1</li>
<li>Manu item 2</li>
<li>Manu item 3</li>
</ul>
</nav>
</aside>
<div class="right_panel">
<header>
<h1>Name of the website</h1>
</header>
<main>
<img id="lantern" class="f-right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/PlaceholderLC.png/600px-PlaceholderLC.png" alt="">
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. </p>
<h2>Subheading 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius.</p>
</main>
<footer>
<p>Copyright © 2019</p>
</footer>
</div>
</div>
But there is a hack for that - using large margin & padding. Note that you need to remove the height and max-height set on the wrapper - see demo below:
html,body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
background-color: blue;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.wrapper {
margin: 10px auto 30px;
padding: 0;
width: 80%;
background-color: white;
/*height: calc(100% - 40px);
max-height: 100%;*/
overflow: hidden; /* to clear the float */
}
aside.left_panel {
float: left;
min-height: 100%;
width: 130px;
background-color: #9eb9f1;
padding-left: 30px;
overflow-y: auto; /*changed to overflow-y */
margin-bottom: -100000px; /* a large value */
padding-bottom: 100000px; /* a large value */
}
.right_panel {
float: left; /* added */
width: calc(100% - 160px); /* added */
/*margin-left: 160px;*/
margin-bottom: -100000px; /* a large value */
padding-bottom: 100000px; /* a large value */
}
nav ul {
list-style-type: none;
padding: 0;
}
header {
background-color: #6f90d1;
padding: 20px;
}
header h1 {
font-size: 60px;
color: darkblue;
}
main {
padding: 20px 20px 0;
}
main h2 {
color: #6f90d1;
}
main #lantern {
height: 400px;
width: 200px;
}
main img {
margin: 10px;
}
main h2 {
margin-bottom: 30px;
}
main p {
margin-bottom: 30px;
}
footer {
text-align: center;
margin: 10px 0;
}
.f-right {
float: right;
overflow: auto;
}
.f-left {
float: left;
overflow: auto;
}
<div class="wrapper">
<aside class="left_panel">
<nav>
<ul>
<li>Home</li>
<li>Manu item 1</li>
<li>Manu item 2</li>
<li>Manu item 3</li>
</ul>
</nav>
</aside>
<div class="right_panel">
<header>
<h1>Name of the website</h1>
</header>
<main>
<img id="lantern" class="f-right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/PlaceholderLC.png/600px-PlaceholderLC.png" alt="">
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. </p>
<h2>Subheading 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius.</p>
</main>
<footer>
<p>Copyright © 2019</p>
</footer>
</div>
</div>
Using flexboxes
Last, but not the least; and since flexboxes have IE11+ and support in all modern browsers, I'd prefer it - thanks to you for letting me brush up on my knowledge too. :)
html,body {
height: 100%;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
background-color: blue;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
.wrapper {
margin: 10px auto 30px;
padding: 0;
width: 80%;
background-color: white;
/*height: calc(100% - 40px);*/
/*max-height: 100%;*/
display: flex; /* added */
}
aside.left_panel {
/* float: left; */
min-height: 100%;
width: 130px;
background-color: #9eb9f1;
padding-left: 30px;
overflow-y: auto; /* changed to overflow-y*/
}
.right_panel {
/*margin-left: 160px;*/
}
nav ul {
list-style-type: none;
padding: 0;
}
header {
background-color: #6f90d1;
padding: 20px;
}
header h1 {
font-size: 60px;
color: darkblue;
}
main {
padding: 20px 20px 0;
}
main h2 {
color: #6f90d1;
}
main #lantern {
height: 400px;
width: 200px;
}
main img {
margin: 10px;
}
main h2 {
margin-bottom: 30px;
}
main p {
margin-bottom: 30px;
}
footer {
text-align: center;
margin: 10px 0;
}
.f-right {
float: right;
overflow: auto;
}
.f-left {
float: left;
overflow: auto;
}
<div class="wrapper">
<aside class="left_panel">
<nav>
<ul>
<li>Home</li>
<li>Manu item 1</li>
<li>Manu item 2</li>
<li>Manu item 3</li>
</ul>
</nav>
</aside>
<div class="right_panel">
<header>
<h1>Name of the website</h1>
</header>
<main>
<img id="lantern" class="f-right" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/PlaceholderLC.png/600px-PlaceholderLC.png" alt="">
<h2>Subheading 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. </p>
<h2>Subheading 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius. Orci varius natoque penatibus et magnis dis parturient. </p>
<h2>Subheading 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dignissim tristique varius.</p>
</main>
<footer>
<p>Copyright © 2019</p>
</footer>
</div>
</div>
You could remove the floats and set your wrapper to display: flex. Also remove the height properties on the wrapper and the margin-left on the right column.
Essentially I am trying to use the <Div> tag to create a bottom border to separate different content on the page but when I scroll to the bottom and insert the div there to separate them, it will ignore the other tags I have put and attached itself to the previous div separator.
How can I fix this? I tried using a HR tag but it did the same.
This is my code:
div {
margin: 0;
padding: 0;
}
#wrapper {
width: 100%;
margin: 0 auto;
}
#leftcolumn,
#rightcolumn {
border: none;
float: left;
min-height: 450px;
color: white;
}
#leftcolumn {
width: 50%;
}
.container {
margin-left: 10%;
width: 40%;
text-align: center;
}
#rightcolumn {
/* height: 100%;*/
width: 40%;
float: right;
background-color: #c9ccc9;
}
.border {
border-bottom: 40px solid #8dc43f;
}
p {
color: black;
}
.infotext {
color: #8dc43f;
margin-left: 30%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitle {
color: #8dc43f;
margin-left: 25%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitlepower {
color: #8dc43f;
margin-left: 36%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitlecomm {
color: #8dc43f;
margin-left: 17%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.bluetags {
width: 264px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 176px;
margin-top: 4px;
}
.greentags {
width: 264px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 180px;
margin-top: -26px;
}
.orangetags {
width: 280px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 175px;
margin-top: -15px;
}
.image {
position: relative;
width: 80%;
/* for IE 6 */
}
.titleimg {
margin-left: -60%;
margin-right: 10%;
}
imagetext {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
.bgimg {
background-size: cover;
width: 100%;
height: 60%;
border-collapse: collapse;
display: block;
margin: 0;
padding: 0;
}
#container {
height: 400px;
width: 400px;
position: relative;
}
#text {
z-index: 100;
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
left: 43%;
top: 25%;
font-family: 'ABeeZee', sans-serif;
}
#secondtext {
z-index: 100;
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
left: 37%;
top: 30%;
font-family: 'ABeeZee', sans-serif;
}
<div id="cssmenu">
<ul>
<img src="turtletag.png" class="titleimg">
<li><span>Home</span>
</li>
<li><span>Features</span>
</li>
<li><span>App</span>
</li>
<li><span>Products</span>
</li>
<li><span>Support</span>
</li>
</ul>
</div>
<img src="googlestore.png" style="position:absolute; top:210px;left:70px; width: 10%;">
<img src="appstore.png" style="position:absolute; top:320px; left:77px; width:10%;">
Order Tags
<img src="iPhone5_Mockup_Template_Free_by_Ray.png" class="bgimg">
<p id="text">Turtle Tags</p>
<p id="secondtext">Always connected to the nest</p>
<div class="border"></div>
<div id="leftcolumn">
<div class="mainbody">
<img src="bluetags.png" class="bluetags hvr-float">
</div>
<div class="mainbody">
<img src="greentags.png" class="greentags hvr-float">
</div>
<div class="mainbody">
<img src="orangetag.png" class="orangetags hvr-float">
</div>
</div>
<a name="features"></a>
<div id="rightcolumn">
<h2 class="infotext">Features</h2>
<hr class="newstyle">
<img src="battery.png" style="margin-left:40%; width:15%">
<p class="infotexttitle">Long battery life</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse
potenti.
</p>
<img src="speaker-xxl.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitle">Noise Notifications</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
<img src="powericon.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitlepower">Always on</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
<img src="twoway.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitlecomm">Two way communication</p>
<p rows="4" columns="4" style="width:350px; margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
</div>
I've tried changing the css and I can't find anything that would cause it, But a fresh pair of eyes may be able to find something I cannot.
The problem here comes from how you constructed your page. You have a left/right column that was built using floats. when you use float, it takes the content in the float out of the general flow of the page. Try to remove those floats and it should work as expected.
I removed your floats in the fiddle and the border started working right.
https://jsfiddle.net/ahmadabdul3/ghogvcsx/4/
here's a basic idea on how floats work: the top boxes don't overlap because there is no float, but the bottom 2 boxes you only see green because the red one is floated so the green one takes its space. to avoid this, add an explicit height to the floated div, but then you can't have dynamically expanding content. https://jsfiddle.net/ahmadabdul3/bL8qLa6j/2/
and here's a basic idea of how columns work: https://jsfiddle.net/ahmadabdul3/bL8qLa6j/5/
Ok guys I have styled this very well, but there are a few quirks! I have tried everything and it looks great/good as a responsive site, but there are some issues. I cannot get the .therapy section to look the way I want it to. Full page it hugs the left margin, but looks good with my media queries. My question is how do i get it to look good on full page and be responsive as well. Thanks and hugs. I would like the margins to come in a few px and look like it is not using all the white space available. please help.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Home</title>
<link rel="stylesheet" href="something.css" type="text/css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
body{
background-color: #f1f0d1;
font-family: Verdana, Tahoma, Arial, sans-serif;
font-size: 1.125em;
overflow: auto;
}
h1, h2, h3{
text-align: center;
padding-left: 5%;
color: #878e63;
}
p{
padding: 2%;
color: #878e63;
}
img{
text-align: center;
max-width: 100%;
height: auto;
width: auto;
}
#wrapper {
margin: 0 auto;
max-width: 1020px;
width: 98%;
background-color: #fefbe8;
border: 1px solid #878e63;
border-radius: 2px;
box-shadow: 0 0 10px 0px;
overflow: hidden;
}
#callout {
width: 100%;
height: auto;
background-color: #878e63;
overflow: hidden;
}
#callout p {
text-align: right;
font-size: 13px;
padding: 0.1% 5% 0 0;
color: #f1f0d1;
}
#callout p a {
color: #f1f0d1;
text-decoration: none;
}
header {
width: 96%
min-height: 125px;
padding: 5px;
text-align: center;
}
nav ul {
list-style-type: none;
margin: 0;
padding-left: 90px;
}
nav ul li {
float: left;
border: 1px solid #878e63;
width: 15%;
}
nav ul li a {
background-color: #f1f0d1;
display: block;
padding: 5% 12%;
font-weight: bold;
font-size: 18px;
color: #878e63;
text-decoration: none;
text-align: center;
}
nav ul li a:hover, nav ul li.active a {
background-color: #878e63;
color: #f1f0d1;
}
.banner img {
width: 100%;
border-top: 1px solid #878e63;
border-bottom: 1px solid #878e63;
}
.clearfix{
clear: both;
}
.left-col {
width: 55%;
float: left;
margin: 1% 1% 1%;
}
.sidebar: {
width: 40%;
float: right;
margin: 1%;
text-align: center;
}
.therapy {
/*float: left;*/
margin: 0 auto;
width: 100%;
height: auto;
/*padding: 1%;*/
}
.section{
width: 29%;
float: left;
margin: 2% 2%;
text-align: center;
}
footer{
background-color: #878e63;
width: 100%;
overflow: hidden;
}
footer p, footer h3 {
color: #f1f0d1;
}
footer p a {
color: #f1f0d1;
text-decoration: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: inline;
}
ul li img {
height: 50px;
}
#media screen and (max-width: 480px) {
body{
font-size: 13px;
}
}
#media screen and (max-width: 740px){
nav {
width: 100%;
margin-bottom: 10px;
}
nav ul {
list-style-type: none;
margin: 0 auto;
padding-left: 0;
}
nav ul li {
text-align: center;
margin-left: 0 auto;
width: 100%;
border-top: 1px solid #878e63;
border-right: 0px solid #878e63;
border-bottom: 1px solid #878e63;
border-left: 0px solid #878e63;
}
nav ul li a{
padding: 8px 0;
font-size: 16px;
}
.left-col, .sidebar, .section {
width: 100%;
float: left;
margin: 0;
}
}
</style>
</head>
<!-- redo all images on the page and style with css3-->
<body>
<div id="wrapper">
<div id="callout">
<p>Call us at <strong>727-555-5555</strong></p>
</div><!--end callout div-->
<header>
<!--need ne image--><img src="http://www.w3newbie.com/wp-content/uploads/massagelogo.png" alt="Massage" title="Massage by ?">
</header>
<nav>
<ul>
<li class="active">Home</li>
<!--make active later--><li>Contact</li>
<!--make active later--><li>Pricing</li>
<!--make active later--><li>Specials</li>
<!--make active later--><li>Consult</li>
<!--make active later--><li>Consult</li>
</ul>
<div class="clearfix"></div>
</nav>
<div class="banner">
<img src="http://www.w3newbie.com/wp-content/uploads/massagebanner.png" alt="need new" title="new">
</div><!--close banner-->
<!--fix w css--><center><img src="http://www.w3newbie.com/wp-content/uploads/three_sayings.png" alt="need new" title="new"></center>
<section class="left-col">
<!--use h2 tag and css--><p style="text-indent: 50px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie pellentesque at convallis eros. Ut luctus ex eget tempor scelerisque. Praesent blandit velit eu turpis aliquam pellentesque. Cras vel erat eget ligula sollicitudin commodo.Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie pellentesque at</p>
<p style="text-indent: 50px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie pellentesque at convallis eros. Ut luctus ex eget tempor scelerisque.</p>
</section>
<aside class="sidebar">
<div class="therapy">
<img src="http://www.w3newbie.com/wp-content/uploads/therapist.jpg" alt="need new" title="new">
</div><!--close therapy div-->
</aside>
<div class="section">
<h3>Text Text Text Text</h3>
<img src="http://www.w3newbie.com/wp-content/uploads/private.png" alt="need new" title="new">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risus In non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie</p>
</div><!--close section div-->
<div class="section">
<h3>Text Text Text Text</h3>
<img src="http://www.w3newbie.com/wp-content/uploads/sauna-steam.png" alt="need new" title="new">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risusIn non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie</p>
</div><!--close section div-->
<div class="section">
<h3>Text Text Text Text</h3>
<img src="http://www.w3newbie.com/wp-content/uploads/retreat.png" alt="need new" title="new">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In non fringilla risusIn non fringilla risus. Quisque sollicitudin iaculis nunc, ultricies fringilla ex malesuada eu. Quisque a augue in mauris molestie</p>
</div><!--close section div-->
<!--fix w h2 and css --><center><img src="http://www.w3newbie.com/wp-content/uploads/ease.png" alt="need new" title="new"></center>
<footer>
<div class="section">
<p>Text Text Text</p>
<p><strong>727-555-5555</strong><br>
123 Main St<br>
Anywhere, FL 33770<br>
blank#blahblah.com</p>
</div>
<div class="section">
<p>Connect with us!</p>
<ul>
<li><img src="http://www.w3newbie.com/wp-content/uploads/facebook1.png" alt="need new" title="new"></li>
<li><img src="http://www.w3newbie.com/wp-content/uploads/googleplus.png" alt="need new" title="new"></li>
<li><img src="http://www.w3newbie.com/wp-content/uploads/twitter1.png" alt="need new" title="new"></li>
<li><img src="http://www.w3newbie.com/wp-content/uploads/youtube1.png" alt="need new" title="new"></li>
</ul>
</div>
<div class="section">
<img src="http://www.w3newbie.com/wp-content/uploads/plant.png" alt="need new" title="new">
</div>
</footer>
</div><!--end wrapper div-->
<p>© 2014.</p><!--margin 0 auto this-->
</body>
</html>
I know it is a lot, but I am stuck, I think my math is off. Please advise me how I can resolve and thank you.
I found a typo (an unecessary colon):
.sidebar: { /*here*/
width: 40%;
float: right;
margin: 1%;
text-align: center;
}
If you want to improve the use of white space, you need to make a concept at first. For example your text is currently above a huge image. Unter this huge image there are three smaller boxes.
So you could say in full screen you want the image and text next to each other. This is done by adding the following to the media query you want the text and image to appear next to each other:
aside.sidebar {
width: 40%;
float: right;
margin-right: 2%;
margin-top: 30px;
}
Then you need to insert
<div style="clear: both;"></div>
Below the closing </aside> tag! You have inserted something like this for your sidebar in line 106 with .sidebar:, which is a "broken code" because of the : after your css class.
This is a quite simple example, but works for all kinds of pages. If you need further explanations feel free to ask, this is a "quick help" copy & paste solution.
Best regards,
Marian.
As Illustrated in the next graphic I have a problem with my responsive code: I have 3 sections called square1, 2 and 3 with a white div inside. text on top of it and an icon with an absolute position. Everything fine from 920px to higher browsing. Now, from 720 to 940 pixels I'm trying to give this 3 elements a 50% of width, to display two on top and 1 at the bottom, but centered. so far is a mess. Could someone explain me what I'm doing wrong? my actual DEMO
HTML:
<div id="section2">
<div id="centralize2">
<div id="square1">
<div id="white1">
<img src="images/hexagon1.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur1</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square2">
<div id="white1">
<img src="images/hexagon2.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur2</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square3">
<div id="white1">
<img src="images/hexagon3.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur3</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
</div>
</div>
Thanks!!
You can use flexbox to achieve what you want. Don't use absolute positioning if it's not necessary. If the width is bigger than 940px, the divs will display next to each other. Try it out in the full version of the code snippet.
Also cleaned up some code, as you can't have multiple divs with the same id. That's not valid markup. Use a class instead.
#section2 {
position: relative;
background-color: #112e4c;
overflow: hidden;
}
#square1, #square2, #square3 {
margin-top: 59px;
}
.white1 {
margin: 20px;
background-color: #fff;
text-align: center;
}
.hexagon {
position: absolute;
left: 50%;
}
.title1 {
font-size:18px;
margin-top: 90px;
font-family: 'Ubuntu', sans-serif;
color: #112e4c;
font-weight: 600;
}
.description2 {
font-size: 14px;
line-height: 16px;
margin-top:20px;
padding-left: 20px;
padding-right: 20px;
text-align: center;
color: #8da0b4;
}
#media all and (min-width:720px) {
#centralize2 {
display: flex;
flex-flow: row wrap;
}
#square1, #square2, #square3 {
flex-basis: calc(50%);
}
}
#media all and (min-width:940px) {
#square1, #square2, #square3 {
flex-basis: calc(100%/3);
}
}
<body>
<div id="section2">
<div id="centralize2">
<div id="square1">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur1</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square2">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur2</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square3">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur3</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
</div>
</div>
</body>
It has to do with your absolute positioning. Try removing the absolute positioning, and try floating the blocks left and add your margins as needed. Will try and get a working demo together for you asap, at work atm.
Got a chance to try and edit your demo, I believe you're looking for something like this https://jsfiddle.net/ah5zz8qq/
#section2 {
width: 100%;
background-color: #112e4c;
overflow: hidden;
}
#centralize2 {
width: 880px;
height: 310px;
margin: 40px auto;
text-align: center;
}
#square1 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#square2 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#square3 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#white1 {
width: 280px;
height: 250px;
background-color: #fff;
text-align: center;
position: relative;
}
.hexagon {
position: absolute;
left: 50%;
top: 0;
margin-left: -52px;
margin-top: -59px;
}
.title1 {
display: block;
font-size:18px;
font-family: 'Ubuntu', sans-serif;
color: #112e4c;
font-weight: 600;
}
.description2 {
font-size: 14px;
line-height: 16px;
margin-top:20px;
padding-left: 20px;
padding-right: 20px;
text-align: center;
color: #8da0b4;
}
#media all and (max-width:940px) {
#centralize2 {
width: 90%;
}
#section2 {
height: 720px;
}
#square1 {
display: block;
width: 50%;
float: left;
}
#square2 {
display: block;
width: 50%;
float: left;
margin-bottom: 10px;
}
#square3 {
display: block;
clear: both;
width: 50%;
float: none;
margin: 0 auto;
}
#white1 {
width:300px;
}
}
#media all and (max-width:720px) {
#section2 {
height: 1070px;
}
#buttons {
margin-top:25px;
}
#square1 {
width: 100%;
}
#square2 {
width: 100%;
margin-top:340px;
}
#square3 {
width: 100%;
margin-top:340px;
}
#white1 {
width: 100%;
position: absolute;
}
}
}