I have php code:
<?php
function metro_page_card($page) {
$html = "\t<li>\n\t\t<a href=\"".get_page_link($page->ID)."\">\n";
$icon = get_post_meta($page->ID, "Icon", true);
$html .= "\t\t\t".wp_get_attachment_image($icon, array('96', '96'))."\n";
$html .= "\t\t\t<p>".$page->post_title."</p>\n";
$html .= "\t\t\tSome text\n";
$html .= "\t\t</a>\n\t</li>\n";
return $html;
}
//[child_pages]
function metro_child_pages() {
$id = get_the_ID();
$pages = get_pages(array('child_of' => $id));
$html = "<ul class=\"page_card_grid\">\n";
foreach($pages as $page) {
$html .= metro_page_card($page);
}
$html .= "</ul>\n";
return $html;
}
add_shortcode('child_pages', 'metro_child_pages');
?>
Rendered html source:
ul.page_card_grid li {
display: inline-block;
width: 200px;
height: 200px;
margin: 20px;
}
ul.page_card_grid li a {
display: inline-block;
color: #555;
width: 200px;
height: 200px;
padding: 20px 16px 16px 16px;
font-size: 16px;
text-decoration: none;
background-color: #fff;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}
ul.page_card_grid li a p {
margin: 8px 0 8px 0;
font-size: 20px;
text-align: center;
}
ul.page_card_grid li a img {
margin: 0 52px 0 52px;
}
ul.page_card_grid li a:hover {
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.19);
}
<ul class="page_card_grid">
<li>
<a href="http://local/index.php/sample-page/child-page-1/">
<img width="96" height="96" src="http://local/wp-content/uploads/2016/05/ic-1-150x150.png" class="attachment-96x96 size-96x96" alt="ic_timetable" srcset="http://local/wp-content/uploads/2016/05/ic-1-150x150.png 150w, http://local/wp-content/uploads/2016/05/ic-1.png 256w" sizes="(max-width: 96px) 100vw, 96px" />
<p>Child page 1</p>
Some text
</a>
</li>
<li>
<a href="http://local/index.php/sample-page/child-page-2/">
<p>Child page 2</p>
Some text
</a>
</li>
</ul>
I want show these card in single line. If it hasn't enough screen space then a part of cards must move to new line and etc. But I have a very strange result at this moment.
How can I fix this bug?
P.S. I don't know maybe it's important but I need to all card area works like link (To the user can click in any place of card).
Try with vertical-align property to this element : ul.page_card_grid li
It fixed the issue :
ul.page_card_grid li {
display: inline-block;
vertical-align: top;
width: 200px;
height: 200px;
margin: 20px;
}
ul.page_card_grid li a {
display: inline-block;
color: #555;
width: 200px;
height: 200px;
padding: 20px 16px 16px 16px;
font-size: 16px;
text-decoration: none;
background-color: #fff;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
}
ul.page_card_grid li a p {
margin: 8px 0 8px 0;
font-size: 20px;
text-align: center;
}
ul.page_card_grid li a img {
margin: 0 52px 0 52px;
}
ul.page_card_grid li a:hover {
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.19);
}
<ul class="page_card_grid">
<li>
<a href="http://contedevel.local/index.php/sample-page/child-page-1/">
<img width="96" height="96" src="http://contedevel.local/wp-content/uploads/2016/05/ic_timetable-1-150x150.png" class="attachment-96x96 size-96x96" alt="ic_timetable" srcset="http://contedevel.local/wp-content/uploads/2016/05/ic_timetable-1-150x150.png 150w, http://contedevel.local/wp-content/uploads/2016/05/ic_timetable-1.png 256w" sizes="(max-width: 96px) 100vw, 96px" />
<p>Child page 1</p>
Some text
</a>
</li>
<li>
<a href="http://contedevel.local/index.php/sample-page/child-page-2/">
<p>Child page 2</p>
Some text
</a>
</li>
</ul>
Related
I am trying to generate a pdf file from HTML using the dompdf package in laravel. When I am trying to load the view in the browser everything works perfectly but when I generate the pdf of the same view file , the CSS styling break.
In the browser it looks like this,
In pdf file it looks like this,
this is my HTML code,
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css" media="all">
body {
width: 100%;
height: 100%;
margin: 20px;
padding: 0;
background-color: #FAFAFA;
font: 12pt "Tahoma";
}
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
#page {
size: A4;
margin: 0;
}
#media print {
html,
body {
width: 210mm;
height: 297mm;
}
.page {
margin: 0;
border: initial;
border-radius: initial;
width: initial;
min-height: initial;
box-shadow: initial;
background: initial;
page-break-after: always;
}
}
* {
box-sizing: border-box;
}
body {
margin-top: 80px;
font-family: "HelveticaNeue-CondensedBold", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
.card {
height: 320px;
width: 530px;
margin: 0 auto;
background: #ECECEC;
border-radius: 4px;
}
.card header {
background: #ED3D34;
height: 90px;
width: 100%;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom: 2px solid rgba(180, 80, 80, .5);
border-top: 1px solid rgba(221, 108, 108, .8);
padding: 35px 20px;
opacity: .9;
}
.card header h1 {
color: #fff;
line-height: 90%;
font-size: 20px;
margin: 0;
text-shadow: -1px -1px 1px rgba(0, 0, 0, .5);
}
.card article {
padding: 20px;
}
.card article img {
float: left;
margin-right: 30px;
width: 130px;
height: 177px;
transition: all .3s ease-in-out;
}
.card article h2 {
color: #515355;
float: left;
margin: 0 5px 15px 0;
font-weight: normal;
padding: 0 0 8px 0;
width: 250px;
}
.card article .area {
height: 170px;
width: 440px;
}
.card article .area h3 {
margin: 0;
color: #5F6163;
font-size: 20px
}
.card article .area ul {
margin: 5px 0 30px 0;
padding: 0;
list-style: none;
}
.card article .area ul li {
margin: 5px 0 0 0;
font-size: 16px;
color: #94957F;
text-shadow: 0 0 1px rgba(0, 0, 0, .3);
}
.card article .area ul li .bar {
width: 280px;
height: 15px;
display: inline-block;
border-radius: 50px;
float: right;
margin: 0 15px 0 0;
opacity: .9;
background-color: #CACACA;
box-shadow: inset 0 2px 2px rgba(0, 0, 0, .35);
}
.card article .area ul li .bar:before {
left: 0;
width: 0;
height: 15px;
background: rgb(254, 213, 121);
box-shadow:
inset 0 4px 4px rgba(255, 255, 255, .3),
inset 0 -2px 3px rgba(0, 0, 0, .05),
0 1px 0 0px #D29D40;
display: inline-block;
border-radius: 50px;
content: '';
z-index: -1;
}
.card article .area ul li .bar.percent-100:before {
width: 280px;
}
.card article .area ul li .bar.percent-90:before {
width: 260px;
}
.card article .area ul li .bar.percent-80:before {
width: 240px;
}
.card article .area ul li .bar.percent-70:before {
width: 220px;
}
.card article .area ul li .bar.percent-60:before {
width: 200px;
}
.card article .area ul li .bar.percent-50:before {
width: 180px;
}
.card article .area ul li:before {
/* content: '\2605'; */
margin-right: 5px;
}
.card article .area::-webkit-scrollbar {
width: 10px;
}
.card article .area::-webkit-scrollbar-track {
background-color: rgba(217, 217, 217, .5);
border-radius: 50px;
}
.card article .area::-webkit-scrollbar-thumb {
background: rgba(184, 184, 184, .5);
box-shadow:
inset 1px 1px 0 rgba(0, 0, 0, 0.10),
inset 0 -1px 0 rgba(0, 0, 0, 0.07);
border-radius: 50px;
}
</style>
</head>
<body>
<div class='card'>
<header>
<h1 class="text-center">Bright Group Tuition</h1>
</header>
<article>
<img alt='My Pic' id='thumb' src='https://s.cdpn.io/1202/timpietrusky_on_rampage_small_1.jpg'>
<h2>Tim Pietrusky</h2>
<div class='area'>
<ul>
<li>
Std: 10th
</li>
<li>
Batch: B1
</li>
<li>
DOB: 12/12/12
</li>
<li>
Academic Year: 2020-2020
</li>
<li>
Contact Number: 8390790935
</li>
<li>
Address: 911B,Baker Street
</li>
</ul>
</div>
</article>
</div>
</body>
</html>
This is the code to generate pdf file,
public function generateIDCards()
{
// $pdf = PDF::loadView('templates.idcard');
$pdf = \App::make('dompdf.wrapper');
$html = view('templates.idcard')->render();
$pdf->loadHTML($html);
return $pdf->download('card.pdf');
// return $html;
}
Any suggestions would be appreciated...
In your css just change the height to this:
.card
{
height: 400px;
width: 530px;
margin: 0 auto;
background: #ECECEC;
border-radius: 4px;
}
You have to set the Content Type to
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
Hope it helps. Cheers!
I found a bootstrap 4 card snippet but when I integrate it to my WordPress plugin, it seem different from original form.I want to show posts as 3 column.
However some posts hasn't any picture - can someone explain why? Also the gird form isnt equal to original form.
Original snippet:
https://bootsnipp.com/snippets/kzbzW
My website :
http://www.themeforest-deneme2.deniz-tasarim.site/2020/01/03/fhhfh/
My plugin codes:
( I didn't change in styles )
//paste
$args = array(
'post_type' => $settings['post_type'],
'author__in' => $settings['authors2'],
'posts_per_page' => $settings['posts_per_page'],
'orderby' => $settings['orderby'],
'order' => $settings['order'],
);
echo'<div class="row">';
echo'<div class="col-md-12">';
$query = new \WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
//echo "<div style=background:blue> lsdkjf </div>";
// get_template_part( 'template-parts/content', 'masonry' );
// the_title();
//the_content();
?>
<style>
h1{
text-align:center;
margin-bottom:50px;
margin-top:50px;
}
.blog-card-blog {
margin-top: 30px;
}
.blog-card {
display: inline-block;
position: relative;
width: 100%;
margin-bottom: 30px;
border-radius: 6px;
color: rgba(0, 0, 0, 0.87);
background: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.blog-card .blog-card-image {
height: 60%;
position: relative;
overflow: hidden;
margin-left: 15px;
margin-right: 15px;
margin-top: -30px;
border-radius: 6px;
box-shadow: 0 16px 38px -12px rgba(0, 0, 0, 0.56), 0 4px 25px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
}
.blog-card .blog-card-image img {
width: 100%;
height: 100%;
border-radius: 6px;
pointer-events: none;
}
.blog-card .blog-table {
padding: 15px 30px;
}
.blog-table {
margin-bottom: 0px;
}
.blog-category {
position: relative;
line-height: 0;
margin: 15px 0;
}
.blog-text-success {
color: #28a745!important;
}
.blog-card-blog .blog-card-caption {
margin-top: 5px;
}
.blog-card-caption {
font-weight: 700;
font-family: "Roboto Slab", "Times New Roman", serif;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.blog-card-caption, .blog-card-caption a {
color: #333;
text-decoration: none;
}
p {
color: #3C4857;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
.blog-card .ftr {
margin-top: 15px;
}
.blog-card .ftr .author {
color: #888;
}
.blog-card .ftr div {
display: inline-block;
}
.blog-card .author .avatar {
width: 36px;
height: 36px;
overflow: hidden;
border-radius: 50%;
margin-right: 5px;blog-
}
.blog-card .ftr .stats {
position: relative;
top: 1px;
font-size: 14px;
}
.blog-card .ftr .stats {
float: right;
line-height: 30px;
}
</style>
<!-- <div class="col-md-2"> -->
<div class="blog-card blog-card-blog">
<div class="blog-card-image">
<!-- <img class="img" src=<?php //the_post_thumbnail(); ?>> -->
<?php the_post_thumbnail('medium', array('class' => 'img')); ?>
<div class="ripple-cont"></div>
</div>
<div class="blog-table">
<h6 class="blog-category blog-text-success"><i class="far fa-newspaper"></i> News</h6>
<h4 class="blog-card-caption">
<?php the_title(); ?>
</h4>
<p class="blog-card-description">Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
<div class="ftr">
<div class="author">
<img src="https://picsum.photos/id/1005/5760/3840" alt="..." class="avatar img-raised"> <span>Lorem</span>
</div>
<div class="stats"> <i class="far fa-clock"></i> 10 min </div>
</div>
</div>
</div>
</div>
</div>
<?php
//ekleme sonu
}
} else {
echo "<div style=background:red> lsdkjf </div>";
}
Personally, I can't see where you implemented Bootstrap4's grid columns:
I want to show posts as 3 column.
This is how you should implement it in HTML, since I don't do Javascript:
<div class="row">
<div class="col">Content</div>
<div class="col">Content</div>
<div class="col">Content</div>
</div>
Bootstrap has its rows split into 12 parts, so the sum of all columns should add up to 12 otherwise something unexpected may happen but I never tried.
For the md thing that you added, it is supposed to target certain screen sizes, but I don't think it's necessary since you didn't specify anything about resolution.
About the numbers, they are the ratios of the columns. As you want three equal slices, you can ignore the trailing number but just remember to throw in three columns.
If my explanation seems vague, please refer to the documentation.
My divs keep shifting when I resize the page can someone help me with this?
html/php (php for login and page getter)
my html body part with some php for login in and something with the page
<div class="menu">
<img src="logo.png" style=" position: relative; margin-right: 38%">
<ul class="dropdown">
<li><a href="?page=Home" <?php if ($page == 'Home') { ?> id="a-active" <?php } ?> >Home</a>
<ul class="sub_menu">
<li>News</li>
<li>Servers</li>
</ul>
</li>
<li><a href="?page=Forum" <?php if ($page == 'Forum') { ?> id="a-active" <?php } ?> >Forum</a>
<ul class="sub_menu">
<li>Common</li>
<li>Information</li>
<li>Griefs & Player reports</li>
<li>
Unbans
</li>
</ul>
</li>
<li><a href="?page=Information" <?php if ($page == 'Information') { ?> id="a-active" <?php } ?> >Information</a>
<ul class="sub_menu">
<li>
Rules
</li>
<li>
Staff
</li>
<li>
Servers
<ul>
<li>Survival</li>
<li>Games</li>
</ul>
</li>
</ul>
</li>
<li><a href="?page=Topscores" <?php if ($page == 'Topscores') { ?> id="a-active" <?php } ?> > Topscores</a>
<ul class="sub_menu">
<li>Playtime</li>
<li>Kills</li>
<li>Game wins</li>
</ul>
</li>
<li><a href="?page=Donations" <?php if ($page == 'Donations') { ?> id="a-active" <?php } ?> >Donation</a>
</li>
</ul>
<div class="content">
<?php
if ($page == 'Forum') {
include 'forum/index.html';
} elseif ($page == 'Information') {
include 'information/index.html';
} elseif ($page == 'Topscores') {
include 'topscores/index.html';
} elseif ($page == 'Donations') {
include 'donations/index.html';
} elseif ($page == 'Home') {
include 'home/index.html';
} else {
include '404/index.html';
}
?>
</div>
<div class="contentmirror1">
<?php
if (isset($_SESSION['username'])) {
?>
<form width="110px" id="form1" name="form1" method="post" action="logout.php">
<table width="100px" border="0" align="center">
<tr>
<td colspan="2">Welcome</td>
</tr>
<tr>
<td><input readonly type="text" name="name" style="border:none; background-color: transparent;" value="<?php echo htmlspecialchars($_SESSION['username']); ?>"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?php
} else {
?>
<form width="110px" id="form1" name="form1" method="post" action="login.php">
<table width="100px" border="0" align="center">
<tr>
<td colspan="2">Login</td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" id="password" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="button" id="button" value="Login" /></td>
</tr>
</table>
</form>
<?php
}
?>
</div>
<div class="contentmirror" style="Clear: Both;">
spambox/online shizzle
</div>
</div>
my css
.head{
height: 115px;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
background: rgb(200,200,200);
z-index: -999;
}
html {
background: url('background.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.menu{
display: inline-block;
position: absolute;
padding: 2%;
text-align: center;
width: 86%;
left: 0px;
top: 0px;
font-family: arial;
z-index: 0;
}
.menu::after {
padding-top: 56.25%; /* percentage of containing block _width_ */
display: block;
content: '';
}
.content{
float: left;
margin-top: 5%;
width: 60%;
max-width: 60%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.contentmirror{
float: right;
margin-top: -3%;
margin-right: 5%;
max-width: 26%;
width: 26%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.contentmirror1{
float: right;
margin-top: -25%;
margin-right: 8%;
max-width: 26%;
width: 26%;
padding: 1%;
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}
.sidepanelright{
float: right;
}
.main{
text-align: center;
font-family: arial;
font-size: 24px;
}
.pics {
width: 70%;
max-height: 100%;
margin: 0px auto;
}
.pic {
display: none;
background-color: transparent;
border: none;
width: 100%;
max-height: 100%;
}
.menu a{
color: black;
background-color: white;
padding: 5px 10px;
margin: 0px 5px;
border-radius: 10px;
text-decoration: none;
-moz-box-shadow: 0px 0px 20px 0px #4E4E4E;
-webkit-box-shadow: 0px 0px 20px 0px #4E4E4E;
box-shadow: 0px 0px 20px 0px #4E4E4E;
z-index: 0;
}
.menu a:hover{
padding: 7px 12px;
-moz-box-shadow: 0px 0px 30px 0px white;
-webkit-box-shadow: 0px 0px 30px 0px white;
box-shadow: 0px 0px 30px 0px white;
}
#logo{
float: left;
top: -90px;
position: relative;
margin: 5px 0px 0px 5px;
width: 15%;
max-height: 100%;
z-index: 1;
}
.btn:hover, .btn:focus {
color: #333333;
text-decoration: none;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
.btn:hover, .btn:focus, .btn:active, .btn.active, .btn.disabled, .btn[disabled] {
color: #333333;
background-color: #e6e6e6;
}
.btn {
display: inline-block;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
border: 1px solid #cccccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
#btn {
display: inline-block;
padding: 4px 12px;
margin-bottom: 0;
font-size: 14px;
line-height: 20px;
color: #333333;
text-align: center;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
vertical-align: middle;
cursor: pointer;
background-color: #f5f5f5;
background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
background-repeat: repeat-x;
border: 1px solid #cccccc;
border-color: #e6e6e6 #e6e6e6 #bfbfbf;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
border-bottom-color: #b3b3b3;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
#btn:hover, #btn:focus, #btn:active, #btn.active, #btn.disabled, #btn[disabled] {
color: #333333;
background-color: #e6e6e6;
}
#btn:hover, #btn:focus {
color: #333333;
text-decoration: none;
background-position: 0 -15px;
-webkit-transition: background-position 0.1s linear;
-moz-transition: background-position 0.1s linear;
-o-transition: background-position 0.1s linear;
transition: background-position 0.1s linear;
}
#a-active{
color: black;
background-color: #DDDDDD;
padding: 5px 10px;
margin: 0px 5px;
border-radius: 10px;
text-decoration: none;
-moz-box-shadow: 0px 0px 20px 0px #4E4E4E;
-webkit-box-shadow: 0px 0px 20px 0px #4E4E4E;
box-shadow: 0px 0px 20px 0px #4E4E4E;
z-index: 0;
}
#a-active:hover{
background-color: white;
padding: 7px 12px;
-moz-box-shadow: 0px 0px 30px 0px white;
-webkit-box-shadow: 0px 0px 30px 0px white;
box-shadow: 0px 0px 30px 0px white;
}
* { margin: 0; padding: 0; }
body { font: 14px Helvetica, Sans-Serif; }
#page-wrap { width: 800px; margin: 25px auto; }
a { text-decoration: none; }
ul { list-style: none;}
p { margin: 15px 0; }
/*
LEVEL ONE
*/
.drops{
margin-left: 30%;
}
ul.dropdown { position: relative; margin-left: 37%; margin-top: 2%;}
ul.dropdown li { font-weight: bold; float: left; zoom: 1; }
ul.dropdown a:hover { }
ul.dropdown a:active { }
ul.dropdown li a { display: block; padding: 4px 8px; border-right: 1px solid #333;
}
ul.dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */
ul.dropdown li.hover,
ul.dropdown li:hover { color: black; position: relative; }
ul.dropdown li.hover a { color: black; }
/*
LEVEL TWO
*/
ul.dropdown ul { width: 220px; visibility: hidden; position: absolute; top: 100%; left: 0; }
ul.dropdown ul li { font-weight: normal; float: none; }
/* IE 6 & 7 Needs Inline Block */
ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; }
/*
LEVEL THREE
*/
ul.dropdown ul ul { left: 100%; top: 0; }
ul.dropdown li:hover > ul { visibility: visible; }
when I resize the window the divs shifts to the left or down. is there a way to set those divs on one position where they do not shift positions just stay there?
I pretty much didn't understand your code, but made this fiddle to make you understand how to fix the divs.
I would suggest you to avoid float for divs and do something like:
.fix{
/* this is parent div */
display:inline-block ;
white-space:nowrap;
}
.fxchld{
/* these are child divs */
width:50px;
display:inline-block ;
height:50px;
border:1px solid #000;
}
idea is to use display:inline-block ; instead of floats so that they remain fixed to their position
else
you'll have to give large parent div width so that child divs won't wrap
Fiddle will help you understand my point!!
My navigation of my website acts strange 2 buttons go out of the div and i cant find the reason for this.
the thing i want is that the 2 blue buttons are on the right of the div but if i float them they still stay out of the div.
image:
HTML:
<div id="navigation">
<ul>
<li>Home</li>
<li>plaats advertentie</li>
<li>Advertenties</li>
</ul>
<ul>
<?php
session_start();
echo '<div id="login">';
if(isset($_SESSION['username'])){
echo'<li>Profile</li>
<li>Logout</li>';
}else{
echo'<li>Register</li>';
echo'<li>Login</li>';
}
echo '</div>';
?>
</ul>
</div>
CSS:
#navigation{
border:1px solid;
border-radius: 2px;
height:50px;
margin-top:1%;
margin-bottom:1%;
background:#6F4E37;
border-radius:8px;
}
#navigation ul
{
margin: 0;
padding-top:1%;
border:1px solid;
}
#navigation ul li
{
display: inline;
}
#navigation li a
{
padding:10px;
margin:0.5%;
background: #6F4E37;
color:black;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #20538D;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
text-decoration: none;
}
#login li a
{
background:#b2fff1;
padding:10px;
margin:0.5%;
background:#b2fff1;
color:black;
text-decoration: none;
}
#navigation li a:hover {
background: #805a3f;
border: solid 1px #2A4E77;
text-decoration:underline;
}
#login li a:hover
{
background:#4cffdf;
border: solid 1px #2A4E77;
text-decoration:underline;
}
<?php
session_start();
echo '<div id="login">';
if(isset($_SESSION['username'])){
echo'<li>Profile</li>
<li>Logout</li>';
}else{
echo'<li>Register</li>';
echo'<li>Login</li>';
}
echo '</div>';
?>
Then change your CSS:
#navigation {
border:1px solid;
border-radius: 2px;
height:50px;
margin-top:1%;
margin-bottom:1%;
background:#6F4E37;
border-radius:8px;
}
#navigation ul {
margin: 0;
padding-top:1%;
border:1px solid;
}
#navigation ul li {
display: inline;
}
#navigation li a {
padding:10px;
margin:0.5%;
background: #6F4E37;
color:black;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #20538D;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
text-decoration: none;
}
#login {
float:right;
}
#login li {
float:left;
padding-left:10px;
}
#login li a {
background:#b2fff1;
padding:10px;
margin:0.5%;
background:#b2fff1;
color:black;
text-decoration: none;
}
#navigation li a:hover {
background: #805a3f;
border: solid 1px #2A4E77;
text-decoration:underline;
}
#login li a:hover {
background:#4cffdf;
border: solid 1px #2A4E77;
text-decoration:underline;
}
Fiddle Here
First:
white-space is your friend. Don't glue everything in the PHP together.
Second:
It is not allowed to use div immediately as the child of the ul element. If you need to add an id attribute, add it to the ul
<ul id="login">
<?php
session_start();
if (isset($_SESSION['username'])) {
echo '<li>Profile</li>'.
'<li>Logout</li>';
} else {
echo '<li>Register</li>';
echo '<li>Login</li>';
}
?>
</ul>
Third:
Switch the uls places and float the one with id="login" to the right:
<ul id="login">
<?php
session_start();
if (isset($_SESSION['username'])) {
echo '<li>Profile</li>'.
'<li>Logout</li>';
} else {
echo '<li>Register</li>';
echo '<li>Login</li>';
}
?>
</ul>
<ul>
<li>Home</li>
<li>plaats advertentie</li>
<li>Advertenties</li>
</ul>
CSS:
#login {
float: right;
}
Updated answer:
HTML
<div id="navigation">
<ul class="leftnav">
<li>Home</li>
<li>plaats advertentie</li>
<li>Advertenties</li>
</ul>
<ul class="rightnav">
<?php
session_start();
echo '<div id="login">';
if(isset($_SESSION['username'])){
echo'<li>Profile</li>
<li>Logout</li>';
}else{
echo'<li>Register</li>';
echo'<li>Login</li>';
}
echo '</div>';
?>
</ul>
CSS
#navigation{
border:1px solid;
border-radius: 2px;
height:50px;
margin-top:1%;
margin-bottom:1%;
background:#6F4E37;
border-radius:8px;
}
#navigation ul
{
margin: 0;
padding-top:1%;
border:1px solid;
}
#navigation ul.leftnav {
float: left;
}
#navigation ul.rightnav {
float: right;
}
#navigation ul li
{
display: inline;
}
#navigation li a
{
padding:10px;
margin:0.5%;
background: #6F4E37;
color:black;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
border: solid 1px #20538D;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
text-decoration: none;
}
#login li a
{
background:#b2fff1;
padding:10px;
margin:0.5%;
background:#b2fff1;
color:black;
text-decoration: none;
}
#navigation li a:hover {
background: #805a3f;
border: solid 1px #2A4E77;
text-decoration:underline;
}
#login li a:hover
{
background:#4cffdf;
border: solid 1px #2A4E77;
text-decoration:underline;
}
I'm making a website in HTML, CSS, and PHP and the page goes way beyond the screen but there is no scroll bar provided by the browser (Safari 5.0.6 and Firefox 14.0.1 on Mac). Is it because I included the PHP? But shouldn't that be there before the page is rendered?
Here is a link: test website
My PHP syntax:
<div id="content">
<div class="wrapper">
<div id="home" class="alert">
Welcome to always4freeĀ©! To browse the classifieds, you must first either choose a location or have your location detected.
</div>
<?php include "res/pages/categories.php"; ?>
</div>
</div>
</div>
What is going on?
EDIT: Here is my CSS:
body {
background-image: url("http://always4free.org/site/images/bg.jpg");
background-size: cover;
font-family: "Mouse Memoirs",sans-serif;
}
.wrapper {
margin: 0 auto;
width: 850px;
}
#header {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5);
border-bottom: 3px solid green;
box-shadow: 0 2px 10px #888888;
height: 50px;
left: 0;
position: fixed;
top: 0;
width: 100%;
}
#logo {
color: rgba(255, 255, 255, 0.7);
float: left;
font-family: "Wendy One",sans-serif;
font-size: 30px;
line-height: 50px;
width: 250px;
}
#logo a:hover {
color: #FFFFFF;
}
#nav {
float: right;
line-height: 50px;
width: 600px;
}
#nav a:first-child {
margin-left: 0;
}
#nav a:last-child {
margin-right: 0;
}
#nav a:link, #nav a:visited {
color: rgba(255, 255, 255, 0.9);
font-family: "Mouse Memoirs",sans-serif;
letter-spacing: 1px;
margin-left: 10px;
margin-right: 10px;
}
#nav a:hover {
border-bottom: 2px solid #FFFFFF;
color: #FFFFFF;
padding-bottom: 1px;
}
#nav a.detect {
background-color: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(255, 255, 255, 0.4);
border-radius: 2px 2px 2px 2px;
color: rgba(0, 0, 0, 0.7);
padding: 5px;
}
#nav a.detect:hover {
color: #000000;
}
#content {
font-family: "Mouse Memoirs",sans-serif;
letter-spacing: 1px;
margin-top: 70px;
}
.page {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5);
border: 1px solid green;
color: #FFFFFF;
font-size: 20px;
padding: 10px;
}
.alert {
background: none repeat scroll 0 0 #AD2E1D;
border: 1px solid #911E0F;
color: white;
font-size: 20px;
padding: 10px;
text-align: center;
}
#categories {
margin-top: 20px;
}
#categories h2 {
color: rgba(255, 255, 255, 0.7);
font-family: "Wendy One",sans-serif;
font-size: 26px;
}
#categories a:link, #categories a:visited {
background: none repeat scroll 0 0 white;
color: black;
padding: 3px;
}
#categories .block {
line-height: 35px;
}
You have all of your content wrapped inside an element of position: fixed;. The body is not able to retrieve the height of fixed or absolute children and is therefore set to an actual height of 0 - thus eliminating any need for scrolling.
If you move your #content element outside of the fixed header things should be working as expected.
Move your div with id content outside of your header div.
It will solve your problem.
Add a clearfix class with your .wrapper so that it have a height and then use:
.wrapper{
overflow: scroll;
}
add overflow: scroll; in your #header style and change position to relative.
#header {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.5);
border-bottom: 3px solid green;
box-shadow: 0 2px 10px #888888;
height: 50px;
left: 0;
position: **relative**;
top: 0;
width: 100%;
**overflow: scroll;**
}