I am making a simple wordpress theme for a friend that will be designed specifically for the content he will be posting. I am now in te process of switching out the temporary static content for dynamic php content.
I have limited knowledge of CSS and usually spend half the time googleing things, and now I have encountered the first real problem that I cant find a solution to myself. In the index.php-part of my theme is a div that contains two floated divs, left (main content) and right (extra stuff), the left one will always have content in it (the WP loop fetching the news posts) while the one on the right may at times be empty (here I have a loop that fetches the featured image of posts that I want to highlight, linking to that post).
Now if no posts are shown in the right div, the containing div ignores the left div and collapses. I previously had the problem of it collapsing anyway, which I solved by giving the container this CSS:
overflow: auto;
}
* html #main {
height: 1%;
}
Here is my html for the index.php (static content in 'main_left' will be replaced with a WP loop later):
<?php get_header(); ?>
<div id="main"><div id="main_left"><h2>Välkommen till Klamas Kultur & Nöje!</h2><p class="small">Klamas Kultur & Nöje producerar fars, komedi och barnteater – både inomhus och utomhus – i hela Västsverige, och har gjort så sedan 1987.</p><hr />
<h1>TURNÉ - Våren 2015</h1><p class="small">Publicerat 2014-12-09 18:42</p>
<p>Efter höstens stora succé, med utsålda hus på Fjärås Bygdegård, ger sig gänget under våren 2015 ut på en liten turné. Första stopp blir Vänersborgs Teater där det blir nypremiär SÖNDAG 18/1 kl. 15.00. Då kommer dessutom ett antal Tvåstadsbekantingar att dyka upp på scen, nämligen Thomas Fridén, Maria Zeffer Johnsson samt Thomas Green. Fyra veckor varar spelperioden för att sedan avslutas med att original-ensemblen återförenas för en finalhelg med föreställningar på Dergårdsteatern i Lerum LÖRDAG 14/2 kl. 19.00 samt på Kungsbacka Teater SÖNDAG 15/2 kl. 15.00.</p>
<h1>TURNÉ - Våren 2015</h1><p class="small">Publicerat 2014-12-09 18:42</p>
<p>Efter höstens stora succé, med utsålda hus på Fjärås Bygdegård, ger sig gänget under våren 2015 ut på en liten turné. Första stopp blir Vänersborgs Teater där det blir nypremiär SÖNDAG 18/1 kl. 15.00. Då kommer dessutom ett antal Tvåstadsbekantingar att dyka upp på scen, nämligen Thomas Fridén, Maria Zeffer Johnsson samt Thomas Green. Fyra veckor varar spelperioden för att sedan avslutas med att original-ensemblen återförenas för en finalhelg med föreställningar på Dergårdsteatern i Lerum LÖRDAG 14/2 kl. 19.00 samt på Kungsbacka Teater SÖNDAG 15/2 kl. 15.00.</p>
<h1>TURNÉ - Våren 2015</h1><p class="small">Publicerat 2014-12-09 18:42</p>
<p>Efter höstens stora succé, med utsålda hus på Fjärås Bygdegård, ger sig gänget under våren 2015 ut på en liten turné. Första stopp blir Vänersborgs Teater där det blir nypremiär SÖNDAG 18/1 kl. 15.00. Då kommer dessutom ett antal Tvåstadsbekantingar att dyka upp på scen, nämligen Thomas Fridén, Maria Zeffer Johnsson samt Thomas Green. Fyra veckor varar spelperioden för att sedan avslutas med att original-ensemblen återförenas för en finalhelg med föreställningar på Dergårdsteatern i Lerum LÖRDAG 14/2 kl. 19.00 samt på Kungsbacka Teater SÖNDAG 15/2 kl. 15.00.</p>
</div>
<div id="main_right">
<div id="main_right_top"><h3>AKTUELLT</h3></div>
<?php query_posts('cat=4 &posts_per_page=3'); while (have_posts()) : the_post(); ?>
<div class="main_right_contents"><?php the_post_thumbnail('category-thumbnail'); ?>Mer info & Bokning</div>
</div>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>
The 'main'-div is inside two additional divs spanning the entire layout; 'dropshadow' and 'wrapper'.
This is the full CSS stylesheet:
body {
margin: 0px;
background-attachment: fixed;
background-image: url(graphics/burnBG.jpg);
background-repeat: repeat-y;
background-position: center top;
}
#dropshadow {
width: 990px;
height: 100%;
margin-right: auto;
margin-left: auto;
background-image: url(graphics/dropShadow.png);
background-repeat: repeat-y;
margin-bottom: 0px;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
#wrapper {
width: 950px;
height: 100%;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
#header {
background-color: #FFFFFF;
height: 260px;
width: 950px;
margin-right: auto;
margin-left: auto;
}
#banner {
background-color: #FFFFFF;
margin: 0px;
height: 225px;
width: 100%;
}
#slider_container {
z-index: 9;
position: relative;
}
#logo {
z-index: 10;
margin-top: -225px;
position: relative;
}
#menu {
background-color: #ffff2d;
height: 35px;
margin: 0px;
}
#main {
width: 950px;
height: 100%;
margin-right: auto;
margin-left: auto;
background-color: #FFFFFF;
overflow: auto;
}
* html #main {
height: 1%;
}
#main_left {
width: 572px;
height: 100%;
float: left;
border-right-width: 3px;
border-right-style: dotted;
border-right-color: #ffff2d;
padding-top: 10px;
padding-right: 25px;
padding-bottom: 25px;
padding-left: 25px;
}
#main_right {
float: right;
width: 325px;
height: 100%;
padding-right: 0px;
padding-bottom: 20px;
padding-left: 0px;
}
#main_right_top {
width: 250px;
margin-right: 25px;
margin-left: 20px;
padding-right: 15px;
padding-left: 15px;
height: 28px;
background-image: none;
background-color: #883831;
line-height: 28px;
}
.main_right_contents {
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
width: 280px;
margin-right: 25px;
margin-left: 20px;
background-image: url(graphics/diagonalstripes.png);
background-repeat: repeat;
margin-top: 10px;
}
#main_full {
width: 870px;
height: 100%;
padding-top: 10px;
padding-right: 40px;
padding-bottom: 25px;
padding-left: 40px;
}
#main_full a:link{
font-family: "Trebuchet MS";
color: #000000;
text-decoration: underline;
}
#main_full a:hover{
color: #000000;
text-decoration: none;
background-color:#ffff2d;
}
#main_full a:visited{
font-family: "Trebuchet MS";
color: #000000;
text-decoration: underline;
}
#footer {
width: 950px;
margin-right: auto;
margin-left: auto;
height: 150px;
margin-bottom: 0px;
border-top-width: 7px;
border-top-style: double;
border-top-color: #ffff2d;
background-image: url(graphics/footerBG.jpg);
background-repeat: repeat-x;
}
#footer a:link{
font-family: Arial, Helvetica, sans-serif;
color: #cb867c;
text-decoration: none;
}
#footer a:hover{
color: #000000;
background-color:#ffff2d;
}
#footer a:visited{
font-family: Arial, Helvetica, sans-serif;
color: #cb867c;
}
#footer_contents {
margin: 0px;
height: 130px;
width: 910px;
padding-right: 20px;
padding-left: 10px;
color: #cb867c;
font-size: 11px;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
vertical-align: bottom;
}
#footer_contents_left {
float: left;
width: 600px;
padding-top: 110px;
}
#footer_contents_right {
float: left;
width: 200px;
padding-top: 10px;
padding-left: 110px;
}
#copyright {
width: 865px;
margin-bottom: 0px;
padding-right: 45px;
padding-left: 20px;
padding-top: 3px;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #cb867c;
padding-bottom: 0px;
bottom: 0px;
height: 25px;
text-align: right;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #cb867c;
margin-right: auto;
margin-left: auto;
}
p {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #000000;
font-weight: normal;
}
p.small{
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
font-weight: normal;
}
h1 {
font-family: "Trebuchet MS";
font-size: 18px;
font-style: normal;
color: #000000;
font-weight: bold;
}
h2 {
font-family: "Trebuchet MS";
font-size: 20px;
color: #000000;
font-style: italic;
}
h3 {
font-family: "Trebuchet MS";
font-size: 18px;
font-style: normal;
color: #E9CDC9;
font-weight: bold;
}
h4 {
font-family: "Trebuchet MS";
font-size: 14px;
font-style: normal;
color: #000000;
font-weight: bold;
margin-bottom: 5px;
}
hr {
color: #ffff2d;
background-color: #ffff2d;
height: 2px;
width: 100%;
border: 0px;
}
#main_left a:link {
font-family: "Trebuchet MS";
color: #000000;
text-decoration: underline;
}
#main_left a:hover {
color: #000000;
text-decoration: none;
background-color:#ffff2d;
}
#main_left a:visited {
font-family: "Trebuchet MS";
color: #000000;
text-decoration: underline;
}
.nav {
background-color: #ffffff;
}
.nav ul {
overflow: auto;
width: 950px;
margin: 0;
padding: 0;
}
.nav li {
float: left;
list-style: none;
background-color: #ffff2d;
text-align: center;
padding: 0;
margin: 0;
font-family: "Trebuchet MS";
font-size: 1.2em;
line-height: 35px;
height: 35px;
width: 16.6667%;
width: calc(100% / 6);
font-style: normal;
}
.nav a {
text-decoration: none;
color: #000000;
display: block;
transition: .3s background-color;
}
.nav a:hover {
color: #ffffff;
background-color: #883831;
font-style: italic;
}
.nav a.active {
background-color: #fff;
color: #444;
cursor: default;
}
.boka {
width: 200px;
height: 30px;
line-height: 30px;
background-color: #ffff2d;
text-decoration: none;
color: #000000;
display: block;
margin-right: auto;
margin-left: auto;
transition: .3s background-color;
cursor:pointer;
font-family:Trebuchet MS;
font-size: 1.2em;
padding:6px 8px;
}
.boka:hover {
color: #ffffff;
background-color: #883831;
font-style: italic;
}
.boka:active {
background-color: #fff;
color: #444;
cursor: default;
}
/* Everything below is for ssslider */
.sss {
height: 0;
margin: 0;
padding: 0;
position: relative;
display: block;
overflow: hidden;
}
.ssslide {
width: 100%;
margin: 0;
padding: 0;
position: absolute;
top: 0;
left: 0;
display: none;
overflow: hidden;
}
.ssslide img {
max-width: 100%;
height: auto;
margin: 0;
padding: 0;
position: relative;
display: block;
}
.sssnext, .sssprev {
width: 25px;
height: 100%;
margin: 0;
position: absolute;
top: 0;
background: url('images/arr.png') no-repeat;
}
.sssprev {
left: 3%;
background-position: 0 50%;
}
.sssnext {
right: 3%;
background-position: -26px 50%;
}
.sssprev:hover, .sssnext:hover {
cursor: pointer;
}
I have been trying to fix this for the last 3 hours with no success. Also, there is a margin of a few pixels at the bottom of the page that have been haunting me throughout the project.
Link to site: http://wordpress.klamas.se/
Collapsing Div Issue
You could write in a check for the content and add a space to keep the div from collapsing.
<?php
$args = array(
'cat' => 4,
'posts_per_page' => 3
);
$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
<div class="main_right_contents"><?php the_post_thumbnail('category-thumbnail'); ?>Mer info & Bokning</div>
<?php }
} else {
echo ' ';
}
wp_reset_postdata();
?>
Bottom Margin Issue
The odd margin at the bottom is due to the content being too large for the fixed height footer. With anything content based I wouldn't recommend fixing the height to a pixel value. By applying the gradient using CSS3 with Graceful Degradation and removing the fixed height we ensure the footer will always look correct.
#footer {
width: 950px;
margin-right: auto;
margin-left: auto;
border-top-width: 7px;
border-top-style: double;
border-top-color: #ffff2d;
background: #cd655a;
background: -moz-linear-gradient(top, #cd655a 50%, #672324 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#cd655a), color-stop(100%,#672324));
background: -webkit-linear-gradient(top, #cd655a 50%,#672324 100%);
background: -o-linear-gradient(top, #cd655a 50%,#672324 100%);
background: -ms-linear-gradient(top, #cd655a 50%,#672324 100%);
background: linear-gradient(to bottom, #cd655a 50%,#672324 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cd655a', endColorstr='#672324',GradientType=0 );
}
References
Colorzilla - CSS Gradient Generator - A nice quick CSS3 Gradient Generator.
Related
I want to make a dropdown menu when you are logged in to add a spot for my account and the orders, etc..
My Mess of a page (When logged in):
Heres my code, but it doesnt really do anything but make a mess of my site. (Take note the some of the php was me attempting to display the users name on the page next to welcome.)
<?php
if (isset($_SESSION['userId'])) {
require './includes/dbh.inc.php';
/*$sql = mysqli_query($conn,"SELECT fnidUser, lnidUsers FROM users"); */
$result = mysqli_query($conn, "SELECT fnidUser FROM users");
echo "
<li class='login current2'><a href='#'>Welcome</a>
<ul>
<li class='login'><a href='#'>My Account</a></la>
<li class='login'><a href='#'>My Orders</a></la>
<li class='login'><a href='#'>My Wishlist</a></la>
<li class='login'><a href='#'>My Cart</a></la>
<li class='login'><a action='./includes/logout.inc.php' method='post' name='logout-submit'>Log out</a></la>
</ul>
</li>
";
}
else{
echo "<li class='login current2'><a href='login.php'>Login / Sign up</a></li>";
}
?>
Here is all my styling for the page.
/* Global */
.container{
width: 80%;
margin: auto;
overflow: hidden;
}
ul{
margin: 0;
padding: 0;
}
.button_1 {
height: 49px;
width: 144px;
background: #FF3B3F;
border: 0;
padding-left: 20px;
padding-right: 20px;
color: white;
font-size: 25px;
border-radius: 8px;
cursor: pointer;
}
.button_1:hover{
background-color: #752021;
color: #CCCCCC;
}
.button_1, .roundbutton:focus{
outline: 0;
}
img{
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none;
}
body{
font: 15px/1.5 Arial;
padding: 0;
margin: 0;
background-color: #EFEFEF;
}
.footerc{
float: left;
}
.footerb{
float: right;
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Login Page Stuff */
#login_page{
margin-top: 65px;
margin-right: 150px;
margin-bottom: 65px;
margin-left: 150px;
min-height: 500px;
}
#login_page h1{
text-align: center;
color: #FF3B3F;
font-size: 50px;
text-shadow: 2px 2px 12px #000000;
}
/* Header */
header{
background: #35424A;
color: #FFFFFF;
padding-top: 30px;
min-height: 70px;
border-bottom: #FF3B3F 5px solid;
}
header ul a{
color: #FFFFFF;
text-decoration: none;
text-transform: uppercase;
font-size: 24px;
}
header li{
float: left;
display: inline;
padding: 0px 20px 0px 20px;
}
header #branding{
float: left;
}
header #branding h1{
margin: 0;
}
header nav{
float: right;
margin-top: 25px;
margin-right: 100px;
}
header .highlight, header .current a{
color: #FF3B3F;
font-weight: bold;
}
header .current2 a{
color: #FF3B3F;
}
header a:hover{
color: #CCCCCC;
}
.login a{
color: #FFFFFF;
text-decoration: none;
float: right;
}
.login {
color: #FFFFFF;
text-decoration: none;
float: right;
margin-top: -10px;
margin-right: 10px;
}
/* Login Form Style */
section #login_page td .form{
margin-bottom: 25px;
}
/*Showcase*/
#showcase{
min-height: 500px;
background:url('../img/iphone_showcase.png') no-repeat -50px -50px;
border-bottom: #FF3B3F 5px solid;
/*Scroll Parallax*/
background-attachment: fixed;
}
#showcase h1{
text-align: center;
color: #FF3B3F;
margin-top: 200px;
font-size: 50px;
text-shadow: 4px 4px 12px #000000;
}
/* Boxes */
#boxes{
margin-top: 65px;
}
#boxes .box{
float: left;
width: 30%;
padding: 25px;
}
#boxes .button_1{
align-content: center;
}
#boxes .box2{
float: left;
width: 48%;
min-height: 100px;
}
/* Footer */
footer{
padding: 20px;
margin-top: 200px;
border-top: #FF3B3F 5px solid;
background-color: #35424A;
color: white;
font-weight: bold;
}
footer .fpara, footer .logo{
margin-left: 100px;
}
footer nav{
float: right;
}
footer li{
float: left;
display: inline;
padding: 0px 20px 0px 20px;
}
.fbhover{
background: url('../footer image/facebook_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.fbhover:hover{
background: url('../footer image/facebook_hover_yes.png') no-repeat;
background-size: 100%;
}
.instahover{
background: url('../footer image/insta_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.instahover:hover{
background: url('../footer image/insta_hover_yes.png') no-repeat;
background-size: 100%;
}
.trhover{
background: url('../footer image/twitter_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.trhover:hover{
background: url('../footer image/twitter_hover_yes.png') no-repeat;
background-size: 100%;
}
.sphover{
background: url('../footer image/support_hover_no.png') no-repeat;
border-radius: 50%;
height: 35px;
width: 35px;
margin-top: 42px;
padding: 8px;
cursor: pointer;
background-size: 100%;
transition: 0.5s;
box-sizing: border-box;
}
.sphover:hover{
background: url('../footer image/support_hover_yes.png') no-repeat;
background-size: 100%;
}
/* Apple Store */
section #applestore{
margin-top: 65px;
}
/* Store Sections */
#main {
padding:20px 0;
}
#content {
overflow: hidden;
}
#content #left, #content #right {
float: left;
margin: 0 2%;
width: 63%;
}
#content #right {
margin-left: 0;
width: 30%;
}
#content h3 {
background: -moz-linear-gradient(#ffffff, #F6F6F6); /* FF 3.6+ */
background: -ms-linear-gradient(#ffffff, #F6F6F6); /* IE10 */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #F6F6F6)); /* Safari 4+, Chrome 2+ */
background: -webkit-linear-gradient(#ffffff, #F6F6F6); /* Safari 5.1+, Chrome 10+ */
background: -o-linear-gradient(#ffffff, #F6F6F6); /* Opera 11.10 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#F6F6F6'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#F6F6F6')"; /* IE8+ */
background: linear-gradient(#ffffff, #F6F6F6); /* the standard */
border-bottom: 1px solid #E0E0E0;
color: #3C3C3C;
font-size: 12px;
font-weight: bold;
line-height: 15px;
padding: 11px 0 12px 20px;
text-transform: uppercase;
}
#content ul {
list-style:none outside none;
margin:0;
padding:0;
}
#content #left ul li {
float:left;
padding-bottom: 21px;
width: 33%;
}
#content #left ul li:hover {
background-color: #fbfbfb;
}
#content #right ul li {
border-top: 1px solid #E7E7E7;
overflow: hidden;
}
#content #right ul li:hover {
background-color: #fbfbfb;
}
#content #right ul li:first-child {
border-width: none;
}
#content #left ul li .img {
text-align: center;
}
#content #right ul li .img {
background-color: #FFFFFF;
float: left;
height: 94px;
text-align: center;
width: 113px;
}
#content #left ul li .img img {
height:128px;
width:128px;
}
#content #right ul li .img img {
height:70px;
margin-top: 11px;
width:70px;
}
#content #left ul li .info {
padding: 17px 20px 0 19px;
}
#content #right ul li .info {
float: left;
overflow: hidden;
padding: 17px 0 0 21px;
width: 164px;
}
#content ul li .info .title {
color: #4B4B4B;
display: inline-block;
font-size: 11px;
font-weight: bold;
line-height: 16px;
text-decoration: none;
text-transform: uppercase;
width: 150px;
}
#content ul li .info .title:hover {
color: #049733;
}
#content #left ul li .info p {
color: #7F7F7F;
font-size: 11px;
line-height: 16px;
padding-top: 3px;
}
#content #left ul li .info .price {
background: none repeat scroll 0 0 #F7F7F7;
color: #383838;
font-size: 12px;
font-weight: bold;
line-height: 16px;
margin: 17px 0 10px;
padding: 6px 0 6px 8px;
}
#content #right ul li .info .price {
color: #383838;
font-size: 12px;
font-weight: bold;
line-height: 16px;
padding-top: 25px;
}
#content #left ul li .info .price .st {
color: #7F7F7F;
font-size: 11px;
line-height: 16px;
margin-right: 3px;
}
#content #right ul li .info .price .usual, #content #right ul li .info .price .special {
color: #7F7F7F;
font-size: 12px;
font-weight: normal;
line-height: 16px;
padding-right: 6px;
text-decoration: line-through;
}
#content #right ul li .info .price .special {
color: #FD7A01;
font-weight: bold;
text-decoration: none;
}
#content #left ul li .info .actions {
overflow:hidden;
}
#content #left ul li .info .actions a {
border: 1px solid #E0E0E0;
color: #fd7a01;
display: block;
float:right;
font-size: 11px;
font-weight: bold;
line-height: 16px;
padding: 5px;
text-decoration: none;
}
#content #left ul li .info .actions a:first-child {
color: #009832;
float:left;
}
This is kind of what I'm looking for but like text no image..
Thanks for the help :)
hi try this css from w3school for drop down using hover,
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="dropdown">
<li class='login current2'><a href='#'>Welcome</a>
<div class="dropdown-content">
<ul>
<li class='login'><a href='#'>My Account</a></la>
<li class='login'><a href='#'>My Orders</a></la>
<li class='login'><a href='#'>My Wishlist</a></la>
<li class='login'><a href='#'>My Cart</a></la>
<li class='login'><a action='./includes/logout.inc.php'
method='post' name='logout-submit'>Log out</a></la>
</ul>
</div>
</li>
</div>
This question already has an answer here:
Content appearing behind fixed header
(1 answer)
Closed 5 years ago.
In my project I use headers that are included in the webpage via php's include function. Then adding the page content I noticed that the code written in the page itself isn't added after the header but behind it.
here's the sample page's code:
<?php
require_once '../WebServices/functions.php';
sessionManager();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../style.css">
<title>DevLancer - Developer jobs for freelancers</title>
</head>
<body>
<?php
if (isset($_SESSION["USER_ID"])) {
require_once '../includes/header_signed-in.php';
} else {
require_once '../includes/header.php';
}
?>
<form class="create-roject">
<input type="text" placeholder="project name"><br>
<textarea></textarea>
</form>
<script type="text/javascript" src="/scripts.js"></script>
</body>
</html>
and here's the header file:
<header class="header-full">
<img class="logo" alt="logo" src="/Media/devlancer_vertical.png">
<div class="header-content">
<nav class="header-top">
<ul class="left-nav">
<li>
Post A Project
</li>
<li>
Find work
</li>
</ul>
<ul class="right-nav">
<li>
Become a member
</li>
<li>
Already a member? Log In
</li>
</ul>
</nav>
<nav class="header-bottom">
<ul class="left-nav">
<li>
<a>FAQ</a>
</li>
<li>
<a>Community</a>
</li>
<li>
<a>Blog</a>
</li>
<li>
<a>About Us</a>
</li>
</ul>
<ul class="right-nav">
<li>
<a class="header-contactus">Contact Us</a>
</li>
<li class="header-social">
<!--add social media links here-->
</li>
</ul>
</nav>
</div>
</header>
<?php
require_once '../includes/frmLogin.php';
require_once '../includes/frmRegister.php';
?>
and here's the styling of the header (scss):
.header-full {
width: 100%;
position: fixed;
top: 0px;
height: 128px;
left: 0px;
box-shadow: 0 0 4px 0 rgba(0,0,0,.08), 0 2px 4px 0 rgba(0,0,0,.12);
.logo {
position: absolute;
display: inline;
margin: 0px 50px;
height:128px;
width: 128px;
background-color: red;
}
.header-content {
display: inline-block;
position: absolute;
left: 229px;
border-left: solid 1px #ececec;
top: 0px;
width: calc(100% - 230px);
height: 128px;
.header-top {
display: block;
width: 100%;
height:87px;
border-bottom: solid 1px #ececec;
.nav {
top:0;
margin: 0;
padding: 0;
height: 87px;
list-style-type: none;
padding-left: 40px;
li {
position: relative;
top: -32px;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
margin-left: 20px;
margin-right: 20px;
height: 87px;
input[type="search"] {
position: relative;
padding: 10px;
border-style: solid;
border-color: #0fa20f;
border-width: 3px;
border-radius: 10px;
font-size: 16px;
font-family: sans-serif;
top:-5px;
}
img {
position: relative;
top: 0;
display: inline;
padding: 0;
height: 87px;
border-radius: 50px;
}
img:hover {
cursor:pointer;
}
a:link {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
a:visited {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
a:hover {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
a:active {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
}
}
.left-nav {
display: inline;
float:left;
vertical-align: middle;
list-style-type: none;
margin: 0;
li {
position: relative;
top: 32px;
bottom: 32px;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
margin-left: 20px;
margin-right: 20px;
a:link {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
a:visited {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
a:hover {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
a:active {
text-decoration: none;
color: black;
animation-name: green2black;
animation-duration: .5s;
}
}
}
.right-nav {
display: inline;
float:right;
padding-right: 40px;
vertical-align: middle;
list-style-type: none;
margin: 0;
li {
padding: 10px;
border-style: solid;
border-color: #0fa20f;
border-radius: 15px;
position: relative;
top: 32px;
bottom: 32px;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
margin-left: 10px;
margin-right: 10px;
animation-name: border-black2green;
animation-duration: .5s;
a:link {
text-decoration: none;
color: black;
}
a:visited {
text-decoration: none;
color: black;
}
a:hover {
text-decoration: none;
color: #0fa20f;
}
a:active {
text-decoration: none;
color: black;
}
}
li:hover {
padding: 10px;
border-style: solid;
border-color: black;
border-radius: 15px;
position: relative;
top: 32px;
bottom: 32px;
display: inline;
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
margin-left: 10px;
margin-right: 10px;
animation-name: border-green2black;
animation-duration: .5s;
a:link {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
a:visited {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
a:hover {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
a:active {
text-decoration: none;
color: #0fa20f;
animation-name: black2green;
animation-duration: .5s;
}
}
}
}
.header-bottom {
display: block;
width: 100%;
height: 41px;
.left-nav {
display: inline;
float: left;
margin: 0;
li {
top: 11px;
bottom: 11px;
position: relative;
display: inline;
font-family: sans-serif;
font-size: 16px;
font-weight: bold;
margin-left: 20px;
margin-right: 10px;
}
}
.right-nav {
display: inline;
float: right;
margin: 0;
padding-right: 40px;
padding-left: 0;
li {
top: 11px;
bottom: 11px;
position: relative;
display: inline;
font-family:sans-serif;
font-size: 16px;
font-weight: bold;
margin-left: 10px;
margin-right: 10px;
}
}
}
}
}
I checked everything including z-index and searched the web for similar cases. please help!
found the error: as the header set to fixed it is being removed from the page flow. just added "margin-top: 128px" and everything is fixed. also discovered that it's a duplicate of this question.
I am working in wordpress and I have this menu with 4 menu items.
The problem is that they are touching each other and there is 0
space between which makes it ugly in my opinion.
Now this problem only
occurs in wordpress. So I have to find a solution how to put some space between.
Maybe you guys know a solution without having to install something on WP.
(the codes in the body is exactly as in my wordpress to demonstrate how it looks like. You can enter it and that will put some space between, but unfortunately that doesn't work in wordpress.)
<style>
.smallmenu {
margin: 0 auto;
max-width: 436px;
width: 100%;
}
.Capital {
margin: 0px 0 -5px 0;
line-height: 63px;
font-size: 60px;
font-weight: ligter;
}
.smalltext {
text-align: center;
margin-top: 0px !important;
font-weight: 100px;
font-size: 14px;
}
.smalltextpub {
text-align: center;
margin-top: 0px !important;
font-weight: 100px;
font-size: 14px;
margin-left: -5px;
}
.cornermenu {
display: inline-block;
margin: auto;
border-radius: 25px;
background: #769DBD;
padding: 20px;
width: 100px;
height: 100px;
text-align: center;
color: #fff;
font-family: Arial;
padding-top: 10px;
text-decoration: none;
}
#hoverr:hover {
border-radius: 25px;
background: #464646;
padding: 20px;
width: 100px;
height: 100px;
text-align: center;
color: #fff;
font-family: Arial;
padding-top: 10px;
text-decoration: none;
}
* {
box-sizing: border-box;
}
</style>
<div class="smallmenu"><a id="hoverr" class="cornermenu" href="#methods"><span class="Capital">M</span>
<span class="smalltext">Methods</span></a><a id="hoverr" class="cornermenu" href="#background"><span class="Capital">B</span>
<span class="smalltextpub">Background</span></a><a id="hoverr" class="cornermenu" href="#results"><span class="Capital">R</span>
<span class="smalltext">Results</span></a><a id="hoverr" class="cornermenu" href="#publications"><span class="Capital">P</span>
<span class="smalltextpub">Publications</span></a></div>
Just set a fixed margin on .cornermenu.
Something like margin: 2px
JSFiddle link
.cornermenu {
...
margin: 2px;
...
}
this is a follow-up question to the one posted here. i am trying to get my fonts to show up[ in my laravel website. i tried changing things so SASS will import my fonts, but they're still not showing up on my website. I went to check weaqther the font downloaded in Chrome devtools, but Chrome said the font loaded a 404 error. i checked the link, and the font downloads. Very strange. How do i get my fonts to show up/
Here is my SASS file:
#import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
#mixin fontFace($family,$src,$weight: normal,$style: normal) {
#font-face {
font-family: $family;
src: url('#{$src}'); // IE9 compat
font-style: $style;
font-weight: $weight;
}
}
#include fontFace('Nexabold', 'public/build/fonts/nexaBold.otf')
body {
margin: 0;
background-color: #ecf0f1;
font-family: NexaBold;
}
.mainheader {
height: 75px;
font-family: NexaBold;
font-size: 28px;
line-height: 75px;
text-align: center;
vertical-align: middle;
background-color: #dce0e1; }
.menu {
height: 40px; }
.subcontainter-title{float:left;}
.subcontainer-left {
height: 75px;
float: left;
width:50%;
}
.subcontainer {
height: 75px;
margin: auto; }
.subcontainer-right {
height: 75px;
width: 50%;
float: right; }
.subcontainer-button {
height: 90px;
width: 105px;
float: right;
padding-left: 12px;
padding-right: 12px;
text-align: center;
vertical-align: middle;
line-height: 75px;
font-family: OpenSans;
font-size: 14px; }
.subcontainer-left .subcontainer-button{float:left;}
.subcontainer-button a {
text-decoration: none;
color: black; }
.subcontainer-button a:visited {
text-decoration: none;
color: black; }
.subcontainer-button a:active {
color: black; }
.subcontainer-button a:hover {
border-bottom: 3px solid gray;
cursor: pointer; }
.subcontainer-title {
height: 75px;
float: left;
padding-left: 12px;
padding-right: 12px;
text-align: center;
vertical-align: middle;
line-height: 75px;
font-family: OpenSans;
font-size: 14px; }
.bt-active a {
border-bottom: 3px solid gold; }
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.maincontainer {
height: 700px; }
.textheader {
height: 180px;
text-align: center;
vertical-align: middle;
line-height: 180px;
font-family: NexaLight;
font-size: 48px; }
.ongoing-header {
width: 700px;
margin: auto;
height: 70px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
background-color: #bcc0c1; }
.subheader {
height: 70px;
width: 260px;
font-family: OpenSans;
font-weight: bold;
font-size: 22px;
text-align: center;
line-height: 70px;
vertical-align: middle;
float: left; }
.subheader-menu {
height: 36px;
background-color: #ccd0d1; }
.button {
height: 36px;
width: auto;
margin: auto;
padding-left: 12px;
padding-right: 12px;
text-align: center;
vertical-align: middle;
line-height: 36px;
font-family: OpenSans;
cursor: pointer;
border-radius: 4px;
transition: 0.3s; }
.button:hover {
background-color: #ecf0f1; }
.subheader-right {
float: right;
padding-top: 16px;
width: 260px;
margin: auto;
margin-right: 24px; }
.ongoing-container {
width: 700px;
margin: auto; }
.ongoing-game {
height: 40px;
line-height: 40px;
vertical-align: middle;
text-align: center;
cursor: pointer;
font-family: OpenSans;
transition: 0.3s; }
.ongoing-game:nth-child(even):hover {
background-color: #f3f9fa; }
.ongoing-game:nth-child(odd):hover {
background-color: #f3f9fa; }
.ongoing-game:nth-child(even) {
background-color: #d3d9da; }
.ongoing-game:nth-child(odd) {
background-color: #dce0e1; }
.iconholder {
height: 20px;
width: 20px;
float: left;
margin-top: 4px;
margin-right: 4px; }
#username {
float: left;
height: 40px;
width: 220px;
text-align: left;
padding-left: 24px; }
#btcamount {
float: left;
height: 40px;
width: 220px;
text-align: right;
padding-right: 24px; }
#ongoing {
height: 40px;
width: 212px;
float: left; }
.bitcoinlogo {
height: 15px; }
.helpcontainer {
height: 600px;
width: 500px;
margin: auto;
font-family: OpenSans; }
.helpform {
margin-top: 20px;
height: 400px;
font-size: 12px; }
.helpform textarea {
resize: none;
font-family: OpenSans; }
#issuetext {
height: 100px;
width: 480px; }
#emailtext {
height: 18px;
width: 220px;
font-family: OpenSans; }
.submitbutton {
height: 40px;
width: 180px;
float: none;
margin: auto;
margin-top: 20px;
border: 1px solid gray;
background-color: white;
text-align: center;
vertical-align: middle;
line-height: 40px;
font-size: 14px;
cursor: pointer;
border-radius: 3px;
transition: 0.2s background-color; }
.submitbutton:hover {
background-color: lightgrey; }
I need to do time-line as time-line on facebook, each div under another div.
For blocks I have : -float: left, display: inline-block; but can't remove free space.
<div class="wrap">
<input type="hidden" id="tp" value="<?php echo $tp; ?>" />
<?php
$i=0;
foreach($memes as $key=>$val){
$i++;
if($i!=1){
echo "<br clear='all' />";
echo "<br clear='all' />";
}else{
echo "<br clear='all' />";
}
echo "<h1 class='fd_date' alt='".$key."'>".(($res = dt_diff($key)) ? $res : (($dt = explode("-", $key)) ? $res : ""))." ".getDay($key)."</h1>";
echo "<br clear='all' />";
echo "<div class='memescont'>";
for($cnt=0;$cnt<count($val);$cnt++){
if($cnt%2==0){
echo"
<div class='fd_meme' rel='".$val[$cnt]['id']."' >
<h1 class='title'>".$val[$cnt]['tit']."</h1>
<img width='465px' alt='".trim("Комиксы, мемы - ").$val[$cnt]['tit']."' src='".base_url()."upload/".$val[$cnt]['src']."' />
<div class='social'>
<div class='likes'>Понравилось:</div>
<div class='shared'>Поделиться:</div>
</div>
</div>
";
}else{
echo"
<div class='fd_meme' rel='".$val[$cnt]['id']."' >
<h1 class='title'>".$val[$cnt]['tit']."</h1>
<img width='465px' alt='".trim("Комиксы, мемы -").$val[$cnt]['tit']."' src='".base_url()."upload/".$val[$cnt]['src']."' />
<div class='social'>
<div class='likes'>Понравилось:</div>
<div class='shared'>Поделиться:</div>
</div>
</div>
";
}
}
echo "</div>";
}
?>
<br clear="all" />
</div>
css :
.content {
height: 100%;
overflow: auto;
position: absolute;
width: 100%;
z-index: 3;
}
.head {
display: inline-block;
width: 100%;
z-index: 2;
}
.wraphead {
margin: 5% auto;
left: 0;
right: 0;
clear: both;
display: block;
margin: 0 auto;
width: 1280px;
height: 64px;
background: url(../i/header.png) 0 0 no-repeat;); position: fixed; top: 0; z-index: 2;
}
#logo { width: 145px; height: 38px; background: url(../i/logo.png) 0 0 no-repeat; float:left; margin: 11px 0;}
.links { height: 60px; float: left; margin-left: 115px;}
.links a { float: left; color: #fff; font-size: 14px; font-family: Verdana, Geneva, sans-serif; margin: 17px 90px 23px 0; }
.links a:hover {cursor: pointer;}
.langs {float: left; width: 62px; height: 20px; border: 1px solid #dedede; border-radius: 1px; margin: 17px 0 23px; }
.langs .lang { margin-left: 8px; width: 10px; height: 8px; margin-top: 6px; margin-bottom: 6px; display: inline-block;}
.lang.ru {background: url(../i/ru.png) 0 0 no-repeat;}
.langs span { font-size: 10px; font-family: Verdana, Geneva, sans-serif; font-style: normal; color: #ffffff; float: right; display: inline-block; margin-top: -18px; margin-right: 22px;}
em.lang_select{ width: 5px; height: 3px; background: url(../i/lang_select.png) 0 0 no-repeat; display: inline-block; float: right; margin-top: -11px; margin-right: 10px}
em.lang_select:hover {cursor: pointer; }
.wrap {width: 980px; display: block; margin: 0 auto;}
.memes {width: 100%; display: inline-block;}
.memes .wrap { background: #fff; z-index: -1; -moz-box-shadow: 0 0 3px rgba(0,0,0,0.5); /* Для Firefox */
-webkit-box-shadow: 0 0 3px rgba(0,0,0,0.5); /*Для Safari и Chrome */
box-shadow: 0 0 3px rgba(0,0,0,0.5); /* Параметры тени */ }
.lft { width: 465px; display: inline-block; padding: 10px 0; }
h1.title{ font-size: 20px; color: #000; font-family: Arial, Helvetica, sans-serif; max-width: 460px; display: inline-block; float: left; font-weight: lighter; text-align: left; margin: 4px 0;}
.martop40 { margin-top: 30px; }
.rgt { width: 465px; float:left; display: inline-block; margin: 0 11px; padding-right: 13px; border-right: 2px solid #999999; }
h1.fd_date{ color: #626262; font-size: 16px; font-family: Verdana, Geneva, sans-serif; text-align: center; font-weight: lighter; bottom: 0;}
.line {width: 2px; display: inline-block; position: absolute; margin-left: 2px; background: url(../i/line.png) 0 0 repeat-y; z-index: 0; min-height: 100%; height: auto;}
.memescont {margin: -10px 0;}
.social { height: 80px; width: 469px; background: url(../i/social_bg.png) 0 0 no-repeat; }
.rgt img, .lft img {border: 1px solid #999;}
.fd_meme { width: 465px; float: left; margin: 0 12px; display: inline-block;}
.right { width: 490px; float: left; }
.left { width: 490px; float: right; }
.likes, .shared {font-family: Verdana, Geneva, sans-serif; font-size: 14px; color: #272727; padding-top: 12px; padding-left: 10px; display: inline-block; width: 202px; height:60px;}
pic: http://picshare.ru/view/97355/rand.png.html
ps. Sorry for my bad english.
It sounds like you are looking for the jQuery masonry plugin. See here
This is what it will look like