How to fix one block inside another [duplicate] - html

This question already has answers here:
How can I position my div at the bottom of its container?
(25 answers)
Closed 2 years ago.
I have a question how can I fix the block with likes,comments,author,inside another block,cause if I make less text it will go up
.post {
display: block;
height: 200px;
width: 800px;
background-color: rgba(63, 63, 63, 0.11);
margin: 20px 20px;
}
.title-block {
font-family: Calibri;
font-weight: 100;
font-size: 40px;
background-color: rgba(63, 63, 63, 0.09);
}
.title {
margin-left: 5px;
}
.post-categorie-block {
margin-top: 10px;
font-family: Calibri;
}
.postcat {
font-weight: 600;
}
.text-block {
font-family: Calibri;
padding: 10px 10px 10px 10px;
font-size: 28px;
}
.bottom-post-panel {
font-family: Calibri;
background-color: #cccccc;
width: 800px;
text-align: left;
margin-top: 10px;
}
.misc {
margin-left: 10px;
margin-right: 10px;
font-size: 20px;
}
<section class="blocks">
<div class="post-blocks">
<section class="post">
<article class="title-block">
<a class="title">Lorem Ipsum</a>
</article>
<div class="post-categorie-block">
<a class="cat">Категория:</a>
<a class="postcat">Lorem Ipsum</a>
</div>
<article class="text-block">
<a>Lorem ipsum dolor sit ametamet, ornare sed tellus. Quisque vel elementum dolor, non eleifend nulla. Donec ut volutpat dui, porttitor pellentesque magna.</a>
</article>
<div class="bottom-post-panel">
<a class="misc">Likes: 50</a>
<a class="misc">Comments: 10</a>
<a class="misc">Author: Lorem</a>
</div>
</section>
If I make position fixed, it will fix that block on whole page, I know that it is calculating margin from text block, but how do I make another way to fix it inside post block

You can set the position property of the wrapper div to relative and then in your child div set the position property to absolute and the bottom to 0px;
This will make it stick to the bottom in your wrapper div
.post {
display: block;
height: 200px;
width: 800px;
background-color: rgba(63, 63, 63, 0.11);
margin: 20px 20px;
}
.title-block {
font-family: Calibri;
font-weight: 100;
font-size: 40px;
background-color: rgba(63, 63, 63, 0.09);
}
.title {
margin-left: 5px;
}
.post-categorie-block {
margin-top: 10px;
font-family: Calibri;
}
.postcat {
font-weight: 600;
}
.text-block {
font-family: Calibri;
padding: 10px 10px 10px 10px;
font-size: 28px;
}
.bottom-post-panel {
position: absolute;
font-family: Calibri;
background-color: #cccccc;
width: 800px;
text-align: left;
bottom: 0px;
}
.post-blocks {
position: relative;
}
.misc {
margin-left: 10px;
margin-right: 10px;
font-size: 20px;
}
<section class="blocks">
<div class="post-blocks">
<section class="post">
<article class="title-block">
<a class="title">Lorem Ipsum</a>
</article>
<div class="post-categorie-block">
<a class="cat">Категория:</a>
<a class="postcat">Lorem Ipsum</a>
</div>
<article class="text-block">
<a>Lorem.</a>
</article>
<div class="bottom-post-panel">
<a class="misc">Likes: 50</a>
<a class="misc">Comments: 10</a>
<a class="misc">Author: Lorem</a>
</div>
</section>

Related

How to make a div height and width equal to screen width and height?

I want my first div "panel-1" to take the full width and height of screen.
I have been trying to break this problem from 3 days.
I tried height :100% & width:100 on parent. Then position:relative on section and position:absolute on div. I tried various other solutions on stack overflow. But none helped.
I created a fiddle at:-
https://jsfiddle.net/81uo3zfc/
<div id="navigation_panel">
<ul>
<li>Home</li>
<li>Technologies</li>
<li>Projects</li>
<li>Resources</li>
<li>Contact</li>
</ul>
</div>
<section>
<div id="panel-1">
<p class="lazyText">Hey!</p>
<p class="lazyText">Lorem ipsum dolor </p>
<p class="colorTransition">sit amet consectetur.</p>
<a class="nextBtn" id="nextBtn-1" href="#panel-2">Let's Go <img class="emoji" src="images/hand.svg" alt="Continue Icon"></a>
</div>
</section>
<section>
<div id="panel-2">
<p class="lazyText">Lorem ipsum</p>
<p class="normal lazyText"> dolor, sit amet </p>
<p class="normal">consectetur adipisicing elit. Voluptatum, a.</p>
<a class="nextBtn" id="nextBtn-2" href="#panel-3">Roger That <img class="emoji" src="images/hand.svg" alt="Continue Icon"></a>
</div>
</section>
<section>
<div id="panel-3">
<p class="lazyText">Lorem ipsum</p>
<p class="normal lazyText"> dolor, sit amet </p>
<p class="normal">consectetur adipisicing elit. Voluptatum, a.</p>
<a class="nextBtn" name="nextBtn-3" data="tech" href="javascript:;">Tech Person <img class="emoji" src="images/tech.svg" alt="Tech Icon"></a>
<a class="nextBtn" name="nextBtn-3" data="nontech" href="javascript:;" style="margin-left: 10px;">Non Tech Person <img class="emoji" src="images/non_tech.svg" alt="Non Tech Icon"></a>
</div>
</section>
Please help. I am new to CSS. And i really tried solving it on my own. But failed.
The Problem you ran into is, that the % sizes relate to the last offset parent (the body or the next relative/absolute/fixed element in the parent chain).
Since your offset parent is using the full screen height, elements using 100% will scale to that size too.
The way to go would be a flex layout.
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Set the flex layout to the parent element of the navigation, set the direction to column and size it to screen height. The navigation will remain static size by adding flex-grow:0; flex-shrink:0.
The content will be shown in a additional .content container, wich takes up the rest of the screen space using flex-grow:1;. The entries will will then be scaled to the height of the .content container using height:100%;.
The footer can also be part of this setup, by placing it in the .sizer container and set flex-grow:0; flex-shrink:0
html,body{
height: 100%;
margin:0;
}
.sizer {
display:flex;
flex-direction:column;
height: 100%;
}
.content {
flex-grow:1;
overflow: scroll;
}
#navigation_panel
{
background-color: #15598f;
padding: 2%;
margin: 0;
flex-shrink: 0;
flex-grow: 0;
}
#navigation_panel>ul
{
list-style-type: none;
padding: 0;
margin: 0;
}
#navigation_panel>ul>li
{
display: inline;
margin : 2%;
font-size: 20px;
font-family: 'Open Sans', sans-serif;
font-weight: 600;
}
#navigation_panel>ul>li>a{
text-decoration: none;
color: #ffffff;
}
section
{
width: 70%;
margin-left: auto;
margin-right: auto;
height: 90%;
height:100%;
padding: 20px 0;
box-sizing: border-box;
}
#panel-1,#panel-2,#panel-3,#panel-4,#panel-5,#panel-6
{
border: 4px solid #27a9e0;
position: relative;
padding: 4%;
height: 100%;
box-sizing: border-box;
}
#panel-1 p,#panel-2 p:nth-child(1),#panel-3 p:nth-child(1),#panel-4 p:nth-child(1),#panel-5 p:nth-child(1),#panel-6 p:nth-child(1)
{
font-size: 40px;
font-family: 'Open Sans', sans-serif;
font-weight: bolder;
}
.normal{
font-size: 24px;
font-family: 'Open Sans', sans-serif;
}
.normal-small{
font-size: 20px;
font-family: 'Open Sans', sans-serif;
}
.nextBtn
{
background-color: #15598f;
text-decoration: none;
padding: 20px;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
color: #ffffff;
}
.emoji
{
width: 25px;
margin-left: 5px;
vertical-align: inherit;
transition: 0.5s;
}
.emoji:hover
{
transform: rotate(-30deg);
}
.AdditionalList>li>a
{
color : #1b8ab9;
border-bottom: 1px solid #27a9e066;
text-decoration: none;
margin: auto;
}
.AdditionalList>li
{
margin-bottom: 20px;
}
footer{
margin: 5% 2% 0% 0%;
}
.third{
width: 33%;
padding: 10px;
background-color: #242f4a;
color: #ffffff;
}
/*Technologies Css*/
.techlist>li{
font-size: 34px;
font-family: 'Open Sans', sans-serif;
}
<div class="sizer">
<div id="navigation_panel">
<ul>
<li>Home</li>
<li>Technologies</li>
<li>Projects</li>
<li>Resources</li>
<li>Contact</li>
</ul>
</div>
<div class="content">
<section>
<div id="panel-1">
<p class="lazyText">Hey!</p>
<p class="lazyText">Lorem ipsum dolor </p>
<p class="colorTransition">sit amet consectetur.</p>
<a class="nextBtn" id="nextBtn-1" href="#panel-2">Let's Go <img class="emoji" src="images/hand.svg" alt="Continue Icon"></a>
</div>
</section>
<section>
<div id="panel-2">
<p class="lazyText">Lorem ipsum</p>
<p class="normal lazyText"> dolor, sit amet </p>
<p class="normal">consectetur adipisicing elit. Voluptatum, a.</p>
<a class="nextBtn" id="nextBtn-2" href="#panel-3">Roger That <img class="emoji" src="images/hand.svg" alt="Continue Icon"></a>
</div>
</section>
<section>
<div id="panel-3">
<p class="lazyText">Lorem ipsum</p>
<p class="normal lazyText"> dolor, sit amet </p>
<p class="normal">consectetur adipisicing elit. Voluptatum, a.</p>
<a class="nextBtn" name="nextBtn-3" data="tech" href="javascript:;">Tech Person <img class="emoji" src="images/tech.svg" alt="Tech Icon"></a>
<a class="nextBtn" name="nextBtn-3" data="nontech" href="javascript:;" style="margin-left: 10px;">Non Tech Person <img class="emoji" src="images/non_tech.svg" alt="Non Tech Icon"></a>
</div>
</section>
</div>
</div>
You can use width: 100vw; and height: 100vh to exactly match the screen/viewport size.
Set this:
#panel-1{
width: 100vw;
height:100vh;
}
try this
**css**
html,body{
/*height: 100%;*/
margin:0;
/*border:1px solid black;*/
}
#navigation_panel
{
background-color: #15598f;
padding: 2%;
margin: 0;
}
#navigation_panel>ul
{
list-style-type: none;
padding: 0;
margin: 0;
}
#navigation_panel>ul>li
{
display: inline;
margin : 2%;
font-size: 20px;
font-family: 'Open Sans', sans-serif;
font-weight: 600;
}
#navigation_panel>ul>li>a{
text-decoration: none;
color: #ffffff;
}
section
{
width:100%;
margin-left: auto;
margin-right: auto;
margin-top: 2%;
margin-bottom: 40px;
height: 100%;
}
#panel-1,#panel-2,#panel-3,#panel-4,#panel-5,#panel-6
{
border: 4px solid #27a9e0;
position: relative;
padding: 4%;
height: 90%;
max-height: 600px !important;
}
#panel-1{
height: calc(100vh - 176px);
max-height: inherit !important;
}
#panel-1 p,#panel-2 p:nth-child(1),#panel-3 p:nth-child(1),#panel-4 p:nth-child(1),#panel-5 p:nth-child(1),#panel-6 p:nth-child(1)
{
font-size: 40px;
font-family: 'Open Sans', sans-serif;
font-weight: bolder;
}
.normal{
font-size: 24px;
font-family: 'Open Sans', sans-serif;
}
.normal-small{
font-size: 20px;
font-family: 'Open Sans', sans-serif;
}
.nextBtn
{
background-color: #15598f;
text-decoration: none;
padding: 20px;
font-family: 'Open Sans', sans-serif;
font-size: 20px;
color: #ffffff;
}
.emoji
{
width: 25px;
margin-left: 5px;
vertical-align: inherit;
transition: 0.5s;
}
.emoji:hover
{
transform: rotate(-30deg);
}
.AdditionalList>li>a
{
color : #1b8ab9;
border-bottom: 1px solid #27a9e066;
text-decoration: none;
margin: auto;
}
.AdditionalList>li
{
margin-bottom: 20px;
}
footer{
margin: 5% 2% 0% 0%;
}
.third{
width: 33%;
padding: 10px;
background-color: #242f4a;
color: #ffffff;
}
/*Technologies Css*/
.techlist>li{
font-size: 34px;
font-family: 'Open Sans', sans-serif;
}
set this:
#panel-1{
position:absolute;
top:0px;
left:0px;
bottom:0px;
right:0px;
}

Header and div appear on the same line

So I have my header with a background image set and I want to create a div underneath it so I can write text there, but when I create the new div, the text I write inside of it appears on top of the already created header. I think it is due to the background image I have set. This is one of my first projects made all by my own so if you guys could help me it will be really appreciated.
These are the HTML and CSS files:
body {
margin: 0;
padding: 0;
background-color:#f4f4f4;
float: left;
}
header{
overflow: hidden;
margin: auto;
}
nav {
width: 100%;
height: 50px;
background-color: rgba(192,192,192,0.3);
margin: auto;
}
.wtf {
padding-right: 50px;
position: relative;
bottom: 3px;
}
#logo {
float: left;
color: white;
font-family: 'Concert One', cursive;
padding-left: 20px;
}
p.highlight {
margin: 0;
position: relative;
bottom: 7px;
}
ul {
float:right;
}
li {
display: inline;
padding: 0 10px 0 10px;
}
a {
text-decoration: none;
color: white;
font-size: 21px;
margin: 0 0 3px 0;
font-family: 'Montserrat', sans-serif;
}
li a:hover {
background-color: #ddd;
color: black;
}
.image {
background-image: url('nebula-stars-universe-galaxy-space-4k-kx-1920x1080.jpg');
}
.main {
width: 100%;
height: 400px;
color: white;
text-align: justify;
position: absolute;
font-family: 'Montserrat', sans-serif;
background-image: url('nebula-stars-universe-galaxy-space-4k-kx-1920x1080.jpg')
}
.main p,h1,h3 {
text-align: center;
position: relative;
}
.main h1 {
top: 100px;
font-size: 50px;
}
.main h3 {
top: 120px;
}
.main p {
top: 90px;
font-size: 20px;
}
.development {
position: relative;
}
.development p {
color: red;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Упражнение</title>
<link rel="stylesheet"
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Concert+One" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/solid.css" integrity="sha384-+0VIRx+yz1WBc
</head>
<body>
<header>
<div class="image">
<nav>
<div id="logo">
<h1><p class="highlight">ATANAS DEVELOPING</p></h1>
</div>
<div class="wtf">
<ul>
<li class="current">
Home
</li>
<li>
Services
</li>
<li>
Clients
</li>
<li>
Team
</li>
<li>
Contact
</li>
</ul>
</div>
</nav>
<div class="main">
<p>Can you build the website of my dreams?</p>
<h1>YUP, WE CAN DO THAT.</h1>
<h3>Learn More</h3>
</div>
</div>
</header>
<br>
<div class="development">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi aliquam lacus quis ex malesuada fermentum. Sed fringilla porttitor massa sit amet sollicitudin.</p>
</div>
</body>
</html>
You positioned your .main absolutely:
.main {
position: absolute;
}
With this styling you take .main out of the normal document flow and it is positioned in the top left corner. The other elements stay in regular flow and are right above it. Just get rid of this positioning and you are good to go.
body {
margin: 0;
padding: 0;
background-color:#f4f4f4;
float: left;
}
header{
overflow: hidden;
margin: auto;
}
nav {
width: 100%;
height: 50px;
background-color: rgba(192,192,192,0.3);
margin: auto;
}
.wtf {
padding-right: 50px;
position: relative;
bottom: 3px;
}
#logo {
float: left;
color: white;
font-family: 'Concert One', cursive;
padding-left: 20px;
}
p.highlight {
margin: 0;
position: relative;
bottom: 7px;
}
ul {
float:right;
}
li {
display: inline;
padding: 0 10px 0 10px;
}
a {
text-decoration: none;
color: white;
font-size: 21px;
margin: 0 0 3px 0;
font-family: 'Montserrat', sans-serif;
}
li a:hover {
background-color: #ddd;
color: black;
}
.image {
background-image: url('https://picsum.photos/200/300?image=15');
}
.main {
width: 100%;
height: 400px;
color: white;
text-align: justify;
/* position: absolute; <-- do not position this absolutely */
font-family: 'Montserrat', sans-serif;
background-image: url('https://picsum.photos/1920/1080?image=10')
}
.main p,h1,h3 {
text-align: center;
position: relative;
}
.main h1 {
top: 100px;
font-size: 50px;
}
.main h3 {
top: 120px;
}
.main p {
top: 90px;
font-size: 20px;
}
.development {
position: relative;
}
.development p {
color: red;
}
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Concert+One" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/solid.css" >
<div class="image">
<nav>
<div id="logo">
<h1><p class="highlight">ATANAS DEVELOPING</p></h1>
</div>
<div class="wtf">
<ul>
<li class="current">
Home
</li>
<li>
Services
</li>
<li>
Clients
</li>
<li>
Team
</li>
<li>
Contact
</li>
</ul>
</div>
</nav>
<div class="main">
<p>Can you build the website of my dreams?</p>
<h1>YUP, WE CAN DO THAT.</h1>
<h3>Learn More</h3>
</div>
</div>
<div class="development">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi aliquam lacus quis ex malesuada fermentum. Sed fringilla porttitor massa sit amet sollicitudin.</p>
</div>
Your .main css class has an absolute position. Disabling that fixes the issue
Remove some position property from your css.
.development {
// remove
//position: relative;
}
.main {
width: 100%;
height: 400px;
color: white;
text-align: justify;
// remove
// position: absolute;
font-family: 'Montserrat', sans-serif;
background-image: url(nebula-stars-universe-galaxy-space-4k-kx-1920x1080.jpg);
}
Changing to above would work but your body is floated towards left so remove that too.
body {
margin: 0;
padding: 0;
background-color: #f4f4f4;
// remove
// float: left;
}

Panels are not lining up

I am trying to line up three panels as seen in the screenshot but everything I've tried hasn't fixed the problem. I've tried reducing the panels widths to 30% and floating them, and I have used display:inline and still the problem persists. Any Ideas what is causing this ?
Problem Page
HTML:
<div class="row" id="hscontent">
<div class="small-12 medium-4 large-4 columns" id="skinny">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-A.png" />
</div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead"><h5 class="taba">Our virtual tour !</h5></div>
</br>
<p class="tabpara">Take a virtual tour of the Horseshoe Bar and Restaurant and see for
yourself its unique, alluring and enchanting interior and atmosphere . It’s rich history and
heritage combines in a warm and charming blend that mixes traditional Irish decor with ornate
old World elegance.</p>
</div>
</div>
<div class="small-12 medium-4 large-4 columns" id="skinny">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-B.png" />
</div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead"><h5 class="tabb">See our menus</h5></div>
</br>
<div class="hstabs">
<span class="tabby">Bar Menu</span>
<span class="tabby">Evening Menu</span>
<span class="tabby">Wine Menu</span>
<span class="tabby">Whiskey Menu</span>
<span class="tabby">Gin Menu</span>
</div>
</div>
</div>
<div class="small-12 medium-4 large-4 columns" id="skinny">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-C.png" /></div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead"><h5 class="taba">Our take on trad</h5></div>
</br>
<p class="tabpara">At one of the Horseshoe’s music sessions you’ll see and hear all of the
splendour that is the Irish traditional music session. A local gathering of talented, and soulful
musicians spinning tunes that capture all of the joy, sorrow, humour and heart of a Irish
traditional music set. </p>
</div>
</div>
</div>
</body>
</html>
RELEVANT CSS:
#charset "utf-8";
/* CSS Document */
body {
width:1200px;
}
.row {
max-width: 1200px;
}
#hsback {
width: 1200px;
height: 1320px;
background-image: url('../Images/HSBACK-WIDE.jpg');
background-repeat: no-repeat;
background-position: center center;
padding-right: auto;
padding-left: auto;
}
#hscontent {
margin-top:-640px;
}
#skinny {
width:30%;
float:left;
display:inline;
}
.panela {
display:inline;
}
panelimg {
width: 100%;
}
hr.style1{
border-top: 1px solid #000;
width: 80%;
text-align: center;
box-shadow: none;
}
.panel {
margin-right: auto;
margin-left: auto;
background-color: #2b4e24;
width: 87%;
overflow:hidden;
box-shadow: 7px 7px 5px #000000;
}
.panela img {
overflow:visible;
margin-right: auto;
margin-left: auto;
width: 100%;
}
.panela a {
margin-right: auto;
margin-left: auto;
text-align:center;
}
.taba {
color: #fff;
line-height: 1.0;
font-family: 'Dancing Script', cursive;
font-weight:400;
font-size: 2.1rem;
margin-top:0.5rem;
text-align:center;
width:98%;
border-bottom: 1px Solid #FFFFFF;
padding-bottom: 0.3rem;
}
.tabb {
color: #fff;
line-height: 1.0;
font-family: 'Dancing Script', cursive;
font-weight:400;
font-size: 2.1rem;
margin-top:0.5rem;
text-align:center;
width:98%;
border-bottom: 1px Solid #FFFFFF ;
padding-bottom: 0.3rem;
}
.tabhead {
width: 80%;
margin-right: auto;
margin-left: auto;
}
.tabpara {
color: #fff;
font-family: 'EB Garamond', serif;
font-size: 1.2rem;
line-height: 1.3;
text-align:center;
margin-top: -70px;
word-spacing: -2;
margin-right: auto;
margin-left: auto;
padding:3px;
width:98%;
}
.tabcolor {
background-color: #2b4e24;
}
.hstabs {
margin-top: -3.7rem;
padding-bottom: 0.90rem;
}
.tabby {
color: #fff;
font-family: 'EB Garamond', serif;
font-size: 1.7rem;
line-height: 1.2;
text-align:center;
text-transform: uppercase;
padding-top: 0.15rem;
padding-bottom: 0.15rem;
display:block;
}
.tabby {
text-align:center;
}
A few issues that could be contributing:
You're using invalid tags - </br> is not a tag. I assume you meant <br/>
The HTML structure is invalid. There are incorrectly nested tags and missing closing tags. Please put your HTML through a parser to make sure the HTML is correct. I have made some corrections below.
body {
width: 1200px;
}
.row {
max-width: 1200px;
}
#hsback {
width: 1200px;
height: 1320px;
background-image: url('../Images/HSBACK-WIDE.jpg');
background-repeat: no-repeat;
background-position: center center;
padding-right: auto;
padding-left: auto;
}
#hscontent {
margin-top: -640px;
}
.top-bar {
padding: 2.0rem;
background-image: url('../Images/Menuback-TRANS.png');
background-repeat: no-repeat;
background-position: center center;
background-size: contain;
background-color: transparent;
}
.top-bar li {
padding-top: 3.0rem;
padding-bottom: 2.0rem;
padding-right: 1.5rem;
font-size: 1.7rem;
color: #FFF;
font-family: 'Lora', serif;
text-decoration: none;
list-style-type: none;
}
.top-bar li {
float: left;
}
/* Make CSS more specific */
.top-bar a {
text-decoration: none;
color: #FFF;
float: left;
}
.menulogo img {
float: left;
}
#skinny {
width: 30%;
float: left;
display: inline;
}
.panela {
display: inline;
}
panelimg {
width: 100%;
}
hr.style1 {
border-top: 1px solid #000;
width: 80%;
text-align: center;
box-shadow: none;
}
.panel {
margin-right: auto;
margin-left: auto;
background-color: #2b4e24;
width: 87%;
overflow: hidden;
box-shadow: 7px 7px 5px #000000;
}
.panela img {
overflow: visible;
margin-right: auto;
margin-left: auto;
width: 100%;
}
.panela a {
margin-right: auto;
margin-left: auto;
text-align: center;
}
.taba {
color: #fff;
line-height: 1.0;
font-family: 'Dancing Script', cursive;
font-weight: 400;
font-size: 2.1rem;
margin-top: 0.5rem;
text-align: center;
width: 98%;
border-bottom: 1px Solid #FFFFFF;
padding-bottom: 0.3rem;
}
.tabb {
color: #fff;
line-height: 1.0;
font-family: 'Dancing Script', cursive;
font-weight: 400;
font-size: 2.1rem;
margin-top: 0.5rem;
text-align: center;
width: 98%;
border-bottom: 1px Solid #FFFFFF;
padding-bottom: 0.3rem;
}
.tabhead {
width: 80%;
margin-right: auto;
margin-left: auto;
}
.tabpara {
color: #fff;
font-family: 'EB Garamond', serif;
font-size: 1.2rem;
line-height: 1.3;
text-align: center;
margin-top: -70px;
word-spacing: -2;
margin-right: auto;
margin-left: auto;
padding: 3px;
width: 98%;
}
.tabcolor {
background-color: #2b4e24;
}
.hstabs {
margin-top: -3.7rem;
padding-bottom: 0.90rem;
}
.tabby {
color: #fff;
font-family: 'EB Garamond', serif;
font-size: 1.7rem;
line-height: 1.2;
text-align: center;
text-transform: uppercase;
padding-top: 0.15rem;
padding-bottom: 0.15rem;
display: block;
}
.tabby {
text-align: center;
}
#whiskeyback {
background: url("../Images/NU-WHISKEY-BACK.jpg")!important;
background-size: cover;
width: 100%;
padding: 1.0rem;
}
.whiskey {
font-family: 'EB Garamond', serif;
font-size: 2.8rem;
line-height: 3.0rem;
color: #e8d789;
text-align: center;
text-shadow: 0 0 14px #e8d789;
padding: 0.8rem;
}
.whiskeytitle {
padding-top: 0.5rem;
padding-right: auto;
padding-bottom: 1.5rem;
padding-left: auto;
}
.whiskeyparabig {
color: #f9f8fd;
font-family: 'Lora', serif;
font-size: 1.5rem;
font-weight: 300;
text-transform: uppercase;
line-height: 1.4rem;
text-align: center;
padding-right: 2.5rem;
padding-left: 2.5rem;
margin-top: -1.5rem;
}
.whiskeypara {
color: #f9f8fd;
font-family: 'Lora', serif;
font-size: 1.2rem;
font-weight: 300;
line-height: 1.5rem;
text-align: center;
padding-top: 0.45rem;
padding-bottom: 4.2rem;
padding-right: 3.2rem;
padding-left: 3.6rem;
margin-top: -1.5rem;
}
a {
text-decoration: none;
}
/* Make CSS more specific */
/*img {
display:inline;
}*/
#foota {
background-image: url('../Images/FOOTER-BACK-BIG.jpg');
background-size: contain;
width: 100%;
}
#footmenu {
padding-top: 2.0rem;
padding-bottom: 2.0rem;
}
#footmenua {
padding-top: 1.0rem;
padding-bottom: 2.0rem;
margin-left: 0.1rem;
margin-top: -3.8rem;
}
.footlink {
font-size: 1.5rem;
padding: 1.0rem;
margin-left: 1.0rem;
color: #f9f8fd;
font-family: 'Lora', serif;
}
.footlinka {
font-size: 1.5rem;
padding: 1.0rem;
margin-left: 1.0rem;
color: #f9f8fd;
font-family: 'Lora', serif;
}
.footpic {
margin-top: -5.0rem;
padding-right: 1.0rem;
}
#floatfoot {
display: inline;
}
#floatfoot img {
margin-top: -1.0rem;
}
.footlogo {
margin-top: 0.5rem;
margin-left: 0.8rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.1/css/foundation.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.1/js/foundation.min.js"></script>
<header>
<div class="row" id="hsback">
<div class="top-bar">
<ul>
<li>Menus</li>
<li>Special Offers</li>
<li>Testimonials</li>
<li>Rooms</li>
</ul>
<img class="menulogo" src="Images/VINTAGE-SIGN-3A2.png" />
</div>
</div>
</header>
<div class="row" id="hscontent">
<div class="small-12 medium-4 large-4 columns">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-A.png" />
</div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead">
<h5 class="taba">Our virtual tour !</h5>
</div>
<br/>
<p class="tabpara">Take a virtual tour of the Horseshoe Bar and Restaurant and see for yourself its unique, alluring and enchanting interior and atmosphere . It’s rich history and heritage combines in a warm and charming blend that mixes traditional Irish decor with
ornate old World elegance.</p>
</div>
</div>
<div class="small-12 medium-4 large-4 columns" id="skinny">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-B.png" />
</div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead">
<h5 class="tabb">See our menus</h5>
</div>
<br/>
<div class="hstabs">
<span class="tabby">Bar Menu</span>
<span class="tabby">Evening Menu</span>
<span class="tabby">Wine Menu</span>
<span class="tabby">Whiskey Menu</span>
<span class="tabby">Gin Menu</span>
</div>
</div>
</div>
<div class="small-12 medium-4 large-4 columns">
<div class="panela">
<img class="panelimg" src="Images/HS-TAB-TOP-C.png" />
</div>
<div class="panel" background-color:#2b4e24;>
<div class="tabhead">
<h5 class="taba">Our take on trad</h5>
</div>
<br/>
<p class="tabpara">At one of the Horseshoe’s music sessions you’ll see and hear all of the splendour that is the Irish traditional music session. A local gathering of talented, and soulful musicians spinning tunes that capture all of the joy, sorrow, humour and heart
of a Irish traditional music set. </p>
</div>
</div>
</div>
<div class="row" id="whiskeyback">
<div class="small-12 medium-6 medium-offset-6 large-5 large-offset-7 columns">
<img class="whiskeytitle" src="Images/WHISKEY-GOLD-3.png" />
<p class="whiskeyparabig">Lorem ipsum dolor sit</p>
<p class="whiskeypara">amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Lorem ipsum dolor sit amet. </p>
</div>
</div>
<footer>
<div class="row" id="foota">
<div class="row" id="footmenu">
<div class="small-12 medium-12 large-12 columns">
<img class="footlogo" src="Images/BEHAN'S-FOOTER-LOGO-GOLD-SMALL.png" />
</div>
</div>
<div class="row" id="footmenua">
<div class="small-12 medium-6 large-6 columns">
<span class="footlink ">Our Menus</span>
<a class="footlink " href="default.asp ">Testimonials</a>
<a class="footlink " href="default.asp ">Rooms</a>
<be/>
<a class="footlinka " href="default.asp ">Take a Tour</a>
<a class="footlinka " href="default.asp ">Our Sessions</a>
</div>
<div class="small-12 medium-3 medium-offset-3 large-3 large-offset-3 columns" id="floatfoot">
<img class="footpic" src="Images/Trip-Advisor-Smallest.png" />
<img class="footpic" src="Images/facebook-Smallest.png" />
</div>
</div>
</div>
</footer>

Why does the element drop down

basically i have 3 images and a div.contact sitting next to each other contained in a Section.gallery. div.contact has been floated right and relatively positioned but not the images .
My problem is that i cant get the 'NEWSLETTER' in the footer to occupy the available space on the right, it keeps dropping down.
However when apply a clear:both to footer see what happens.It Creates a huge space between the footer and the Section.gallery ,but 'NEWSLETTER' takes up all the space
When i check with google chrome inspect element, there is a big margin that i did not apply.
The relevant code
the HTML part
<section class="gallery">
<div class="display-gallery">
<img src="images/picture.png" />
<img src="images/picture.png" />
<img src="images/picture.png">
</div>
<!--End gallery-->
<div class="contact">
<p>contact</p>
<h2>booking <br />
<span>0123.456.789</span><br />
<span>0123.456.789</span><br />
<span> contact#xidian.com</span>
</h2>
Find out more
</div>
<!--End-->
</section>
<!--End Section-->
<footer>
<div class="nav-wrapper">
<nav class="footer-nav">
<ul>
<li> Home </li>
<li> Biography </li>
<li> Photo Gallery</li>
<li> Calendar </li>
<li> Videos </li>
<li> Contact me </li>
</ul>
<ul class="second-nav">
<li> Home </li>
<li> Biography </li>
<li> Photo Gallery</li>
<li> Calendar </li>
<li> Videos </li>
<li> Contact me </li>
</ul>
</nav>
<div class="more-info">
<h3>some information here</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipis ellt. Cras non nibh
sed vellt ultrices convallis eget vitae leo. Vestibulum porttitor dolor
sed is semper id consequat urna tristique vivamus sodales, nibh id comisam risti.
</p>
</div>
<div class="follow-me">
<h3>follow me </h3>
<a href="">
<img src="images/youtube.png">
</a>
<a href="">
<img src="images/fb.png">
</a>
<a href="">
<img src="images/twitter.png">
</a>
<a href="">
<img src="images/link.png">
</a>
</div>
<div class="newsletter">
<h3>newsletter</h3>
<p>Lorem ipsum dolor sit amet, consectetur<br />adipiscing ellt. Cras non nibh sed.</p>
<input type="text" name="comment" ><br />
<input type="submit" value="Send" >
</div>
</div>
CSS:
.display-gallery img {
width: 215px ;
height:195px;
margin-right: 30px;
border: 1px solid #D9D9D9;
}
.display-gallery img:hover{
transition-duration: 0.5s ;
transform: scale(1.2);
}
.contact {
float: right;
width: 215px ;
height:195px;
position: relative;
top: -199px;
border: 1px solid #D9D9D9;
}
.contact h2 {
font-size: 16px;
text-transform: uppercase;
line-height: 20px;
padding-left: 12px;
}
.contact p {
text-transform: uppercase;
color: #8e3a17;
font-size: 16px;
padding-top: 20px;
padding-bottom: 18px;
padding-left: 12px;
}
.contact a {
margin-top: 10px;
margin-left: 12px;
}
.nav-wrapper {
outline: solid 1px greenyellow;
overflow: hidden;
border-top: 2px solid #D9D9D9;
border-bottom: 1px solid #D9D9D9;
padding-top: 14px;
padding-bottom: 13px;
}
.footer-nav ul {
float: left;
margin-right: 25px;
}
.footer-nav ul li {
font-size: 10px;
text-transform: uppercase;
line-height: 19px;
}
.second-nav {
margin-right: 25px;
}
.more-info {
border-left: dashed 1px #D9D9D9;
border-right: dashed 1px #D9D9D9;
float: left;
width: 245px;
padding-left: 20px;
padding-right: 20px;
}
.more-info h3 {
font-size: 10px;
text-transform: uppercase;
line-height: 19px;
}
.more-info p {
font-size: 10px;
display: inline-block;
line-height: 13px ;
padding-top: 17px;
width: 210px;
word-break: break-all;
}
.follow-me {
padding: 0 25px 0 25px ;
float: left;
width: 245px;
border-right: 1px dashed #D9D9D9;
}
.follow-me h3 {
text-transform: uppercase;
font-size: 10px;
line-height: 19px;
}
.follow-me img {
padding-top: 17px;
margin-right: 7px;
}
.newsletter {
float: right;
width: 205px;
}
.newsletter h3 {
text-transform: uppercase;
font-size: 10px;
line-height: 19px;
padding-bottom: 7px;
}
.newsletter p {
font-size: 10px;
display: inline-block;
line-height: 13px;
padding-bottom: 6px;
}
input[type= text] {
width: 205px;
height: 20px;
border: 1px solid #D9D9D9;
}
input[type = submit] {
margin-top: 7px;
float: right;
display: inline-block;
background-color: #8e3a17;
font-size: 11px;
color: white;
width: 55px;
height: 20px;
line-height: 15px;
text-align: center;
box-shadow: 1px 1px 2px #8e3a17;
}
Ps:i did apply a css reset
Sorry about the long post
Update the css as follows:
.gallery {
overflow: hidden;
}
.display-gallery {
float: left;
}
.contact {
float: right;
width: 215px ;
height:195px;
/*position: relative;
top: -199px;*/
border: 1px solid #D9D9D9;
}
your first div "display-gallery" catches all the width of the screen. so your "contact" floating right div is added at the bottom of the div block. (remove the "top: -199px" from the second div "contact" and you'll see why when you add clear: both to footer you got this gap).
The margin you get right to the footer is a placeholder of the ".contact" div to which you apply "top: -199px"

Vertical Align & Navigation Problems

Site: http://tripleo.biz/test/index.html
Please shrink browser to mobile view.
Header:
I have problems with the alignment. They don't seem to align all to the middle of the header. The Android logo seems ot be the only thing aligned. The text and dash image aren't. :/
Navigation:
The Navigation Drop Down is in effect when you mouse-over "ALL" but the links after Link 2 are hidden behind the image. I tried to use z-index to fix this issue but nothing still.
Content Area:
Another problem with Vertical align. For some reason there is more space at the bottom of the content.
Index.html
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1">
<link rel="stylesheet" href="css/styled.css">
<!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<header>
<div class="image_carousel">
<img src="images/menu.png" style="width: 15px; height: 22px;" />
<img src="images/android_icon.png" style="margin-top: 10px; width: 26px; height: 46px;" />
<div class="nav">
ALL
<ul>
<li>LINK1</li>
<li>LINK2</li>
<li>LINK3</li>
<li>LINK4</li>
<li>LINK5</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
</header>
<section>
<img src="images/headerimg.jpg" />
<div class="bround">
<img src="images/logo.jpg" class="imgleft" width="75px" />
<b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
<p class="bauthor">Olajide Olaolorun | 1 Comment</p>
</div>
<div class="clearfix"></div>
<div class="bround">
<img src="images/logo.jpg" class="imgleft" />
<b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
<p class="bauthor">Olajide Olaolorun | 1 Comment</p>
</div>
<div class="clearfix"></div>
</section>
<footer>
<p>Copyright Confidential</p>
</footer>
</body>
</html>
CSS
img {
width: 100%;
}
header {
background: #83aa01;
width: 100%;
height: 76px;
/*position: fixed;*/
top: 0;
left: 0;
vertical-align:middle;
}
.image_carousel {
padding: 5px 0 1px 1px;
vertical-align: middle;
text-align: left;
}
.image_carousel img {
border: 0px;
padding: 0px;
margin: 0px;
display: inline-block;
vertical-align: middle;
bottom:0px;
}
.clearfix {
float: none;
clear: both;
}
div.bround {
background-color: #FFF;
color: #000;
padding: 20px;
margin-top: 10px;
margin-right: 0px;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
}
img.imgleft {
position:relative;
float: left;
margin: 0px 5px 5px 0px;
width: 60px;
}
.bauthor {
color: #D3D3D3;
}
.bauthor a {
color: #83aa01;
}
#menu-icon {
display: hidden;
width: 40px;
height: 40px;
font-size: 20px;
}
div.nav {
border: 0px;
padding: 0px;
margin: 0px;
display: inline-block;
vertical-align: middle;
bottom:0px;
color: #FFF;
}
div.nav ul, div.nav:active ul {
display: none;
position: absolute;
padding: 0px;
background: #444;
color: #FFF;
top: 50px;
width: 20%;
border-radius: 4px 0 4px 4px;
}
div.nav li {
text-align: center;
width: 100%;
padding: 5px 0;
margin: 0px;
border-bottom: 1px dotted #FFF;
z-index:1000;
}
div.nav:hover ul {
display: block;
}
div.nav ul, div.nav a {
color: #FFF;
font-size: 17px;
font-weight: normal;
letter-spacing:2px;
}
ul {
list-style: none;
}
li {
display: inline-block;
float: left;
padding: 10px
}
-
Please Help!
Thanks.
For Header :
set your .image_carousel padding-top value to 15px and remove margin-top from your android icon. which looks like this
.image_carousel {
padding: 15px 0 1px 1px;
vertical-align: middle;
text-align: left;
}
Content Area :
You have Given margin-bottom :20px to your p tag Just remove that .
Regarding the Navigation issue, You need to add z-index for the dropdown menu. Update your css like below it will resolve.
div.nav ul, div.nav a
{
color:#fff;
font-size:17px;
font-weight:normal;
letter-spacing:2px;
z-index:10;
}
Regarding the Content Area padding is coming from the following class
section
{
margin:80px auto 40px;
max-width:980px;
position:relative;
padding:20px;
}
If you remove the margin bottom 40px, it will work fine in mobile. But the problem is you wont get enough space on bigger screens. So you can use media query and apply this class only on mobile versions.
#media all and (max-width: 399px)
{
section
{
margin-bottom:0px;
}
}
Test css copy code
header {
background: none repeat scroll 0 0 #83AA01;
height: 76px;
position: relative;
width: 100%;
z-index: 10;
}
.image_carousel {
text-align: center;
vertical-align: middle;
}
.image_carousel img, .image_carousel > .nav {
border: 1px solid #DDDDDD;
display: inline-block;
height: 74px;
line-height: 74px;
padding: 0 30px;
position: relative;
vertical-align: middle;
}
.image_carousel > .nav:hover {
background-color: #FF0000;
}
.image_carousel > .nav ul li {
line-height: normal;
}
.clearfix {
clear: both;
float: none;
}
div.bround {
background-color: #FFFFFF;
border-radius: 15px;
color: #000000;
margin-right: 0;
padding: 20px;
}
img.imgleft {
float: left;
margin: 0 5px 5px 0;
position: relative;
width: 60px;
}
.bauthor {
color: #D3D3D3;
}
.bauthor a {
color: #83AA01;
}
#menu-icon {
display: inline-block;
font-size: 20px;
height: 40px;
width: 40px;
}
div.nav ul, div.nav:active ul {
background: none repeat scroll 0 0 #444444;
border-radius: 4px 0 4px 4px;
color: #FFFFFF;
display: none;
left: 0;
padding: 0;
position: absolute;
width: 100px;
margin-top:30px;
}
div.nav li {
border-bottom: 1px dotted #FFFFFF;
margin: 0;
padding: 5px 0;
text-align: center;
width: 100%;
z-index: 1000;
}
div.nav li:hover{
background-color:red;
}
div.nav:hover ul {
display: block;
top: 43px;
}
div.nav ul, div.nav a {
color: #FFFFFF;
font-size: 17px;
font-weight: normal;
letter-spacing: 2px;
}
ul {
list-style: none outside none;
}
li {
display: inline-block;
float: left;
padding: 10px;
}
//yes test html
<header>
<div class="image_carousel">
<img src="images/menu.png" />
<img src="images/android_icon.png" />
<div class="nav">
ALL
<ul>
<li>LINK1</li>
<li>LINK2</li>
<li>LINK3</li>
<li>LINK4</li>
<li>LINK5</li>
</ul>
</div>
</div>
<div class="clearfix"></div>
</header>
<section>
<img src="images/headerimg.jpg" />
<div class="bround">
<img src="images/logo.jpg" class="imgleft" width="75px" />
<b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
<p class="bauthor">Olajide Olaolorun | 1 Comment</p>
</div>
<div class="clearfix"></div>
<div class="bround">
<img src="images/logo.jpg" class="imgleft" />
<b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis feugiat quam vitae mauris lacinia, id tincidunt eros lobortis.</b>
<p class="bauthor">Olajide Olaolorun | 1 Comment</p>
</div>
<div class="clearfix"></div>
</section>
<footer>
<p>Copyright Confidential</p>
</footer>