Boostrap 4 post card seem different on my website - php

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.

Related

Why does my media query have no effect on my CSS?

I'm making a counter that is contained within a box. I'm trying to make this counter responsive to different screen sizes, but the media query I'm trying to use will not work for some reason.
I have tried changing the the device width to below 768px but the query has no effect on the counter and I'm not sure why. I have included the HTML/PHP code for the counter as well as the CSS. Can anybody figure out why it's not working
I have made sure this tag is included in the head of the document.
<meta name="viewport" content="width=device-width, initial-scale=1">
Code:
.wrapper {
width: 100%;
float: center
}
.counter-container {
top: 14vh;
right: 4%;
float: right;
width: auto;
height: auto;
background-color: rgb(0, 0, 0, 0.7);
border-radius: 4%;
font-family: Trebuchet MS;
color: white;
}
.counter {
margin-bottom: 5px;
}
.count-title {
font-size: 10px;
font-weight: bolder;
margin-top: 0;
margin-bottom: 0;
text-align: center;
line-height: 70px;
}
.count-text {
font-size: 16px;
font-weight: bold;
margin: 5px 20px 10px 20px;
text-align: center;
color: white;
}
.count-dial {
font-size: 14px;
font-weight: normal;
margin: 8px 5px;
text-align: center;
}
.counter-closer {
float: right;
margin: 2px 6px;
padding: 0;
font-size: 18px;
background-color: rgb(0, 0, 0, 0.5);
}
.counter-closer:hover {
-webkit-filter: invert(1);
filter: invert(1);
}
.counter-digit {
background-image: linear-gradient(180deg, rgb(153, 255, 102), rgb(0, 255, 0));
border-radius: 5%;
color: rgb(0, 128, 0);
padding: 5px;
font-size: 30px;
}
.counter-row {
display: flex;
justify-content: center;
width: 100%;
margin-top: 2px;
}
.bottle-icon {
width: 38px;
height: 50px;
margin: 0 10px 10px 0;
}
.rotate-bottle {
transform: rotate(25deg);
-webkit-animation: shake .5s ease-in-out .1s infinite alternate;
}
#-webkit-keyframes shake {
from {
-webkit-transform: rotate(35deg);
}
to {
-webkit-transform: rotate(15deg);
-webkit-transform: rotate(25deg);
}
<div class="counter col_fourth counter-container" id="bottleCounter">
<i class="fas fa-times counter-closer" onclick="closeCounter()"></i>
<div class="counter-row">
<!--NB 19.11.21 green bottle image next to counter-->
<img class="bottle-icon rotate-bottle" src="https://img.resultclothing.net/icons/Green_Bottle.png" alt="water bottle">
<h2 class="count-title count-number">
<?php
$bottleCount = str_split(intval($var));
echo '
<span class="timer counter-digit" data-to="'.$bottleCount[0].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[1].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[2].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[3].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[4].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[5].'" data-speed="5000"></span>
<span class="timer counter-digit" data-to="'.$bottleCount[6].'" data-speed="5000"></span>';
?>
</h2>
</div>
<p class="count-text">
<?php echo constant('LANG_FOOTER_BOTTLES_REC'); ?>
</p>
</div>
the missing closing bracket
Add the closing bracket to you keyframe
#-webkit-keyframes shake {
from{
-webkit-transform: rotate(35deg);
}
to {
-webkit-transform:rotate(15deg);
-webkit-transform:rotate(25deg);
}
}

Responsive div block and text

Hello i am making my own wordpress bootstrap theme. And i have one thing what i want to make that it work nice on mobile and tablets. Right now in mobile mode my site Title in mixed together with my info box. I think it would be nice if i could move my text box under the text box when the page is visited on smaller screens.
You can see my problem in image:
My HTML:
<div class="container">
<div class="wrapper">
<h1>
<?php
if(get_theme_mod( 'header_banner_title_setting' )){
echo get_theme_mod( 'header_banner_title_setting' );
}else{
echo 'Wordpress + Bootstrap';
}
?>
</h1>
<p>
<?php
if(get_theme_mod( 'header_banner_tagline_setting' )){
echo get_theme_mod( 'header_banner_tagline_setting' );
}else{
echo esc_html__('To customize the contents of this
header banner and other elements of your site, go to D
ashboard > Appearance >
Customize','wp-bootstrap-starter');
}
?>
</p>
<div id="headertxt">
<a>Zvani - <span class="head"> (+371) 29429748</span><br />
</a>
<a href="mailto:godeli#tvnet.lv">Raksti - <span
class="head_2">godeli#tvnet.lv</span><br /></a>
<a href="/ka-mus-atrast/">Redzi mūs <span
class="head_2">kartē</span><br /></a>
<a><span class="head">57°11'58.4"N 22°12'11.2"E</span><br />
</a>
<hr>
<a href="./rekviziti/"><span
class="head_2">REKVIZĪTI</span></a>
</div>
</div>
<a href="#content" class="page-scroller"><i class="fa fa-fw fa-
angle-down"></i></a>
</div>
</div>
CSS :
header#masthead {
margin-bottom: 0;
background-color: #563d7c ;
box-shadow: 0 0.5rem 1rem rgba(0,0,0,.05), inset 0 -1px 0 rgba(0,0,0,.1);
padding: .60rem 1rem;
border-bottom: 1px solid #9175bb ;
position: fixed;
z-index: 2000;
width: 100%;
}
.navbar-brand > a {
color: rgba(0, 0, 0, 0.9);
font-size: 1.1rem;
outline: medium none;
text-decoration: none;
color: #fff;
font-weight: 700;
}
.navbar-brand > a:visited, .navbar-brand > a:hover {
text-decoration: none;
}
#page-sub-header {
position: relative;
padding-top: 15rem;
padding-bottom: 0;
text-align: center;
font-size: 1.25rem;
background-size: cover !important;
}
#page-sub-header h1 {
line-height: 1;
text-align: left;
font-size: 4rem;
color: #563e7c;
margin: 0 0 1rem;
border: 0;
padding: 0;
}
#page-sub-header p {
margin-bottom: 0;
text-align: left;
line-height: 1.4;
font-size: 1.25rem;
font-weight: 300;
color: #563e7c;
}
a.page-scroller {
color: #333;
font-size: 2.6rem;
display: inline-block;
margin-top: 2rem;
}
#media screen and (min-width: 768px) {
#page-sub-header h1 {
font-size: 3.750rem;
line-height: 1;
}
#page-sub-header {
font-size: 1.25rem;
}
}
#media screen and (min-width: 992px) {
#page-sub-header p {
max-width: 43rem;
margin: 0 auto;
}
}
#headertxt {
position: absolute;
right: 20px;
bottom: 100px;
background-size: auto;
background: rgba(0, 0, 0, 0.7);
padding: 10px 10px 10px 10px;
}
#headertxt a {
text-align: right;
color: white;
font-size: 20px;
}
I hope someone will lead me to some way how to fix this problem and points me to some good tip. Thanks!

Anybody see what needs fixing in the styling?

So I created a comments section for a WordPress theme I am developing and after a good half hour of trying to figure out what went wrong in the labeling of the styling, I am stumped So the problem is the article.post img styling is affecting the comment-meta img. One should not be affecting the other.
I am also providing what it looks like in Chrome developer tools Elements:
<img alt="" src="http://1.gravatar.com/avatar/4f9ce072cb3fdb377cbb1a083d5c7d1a?s=80&d=mm&r=g" srcset="http://1.gravatar.com/avatar/4f9ce072cb3fdb377cbb1a083d5c7d1a?s=160&d=mm&r=g 2x" class="avatar avatar-80 photo" height="80" width="80">
This is the style.css:
body {
padding-top: 20px;
font-size: 15px;
color: #7a7a7a;
line-height: 1.7em;
}
a {
color: #0faf97;
}
.btn-primary {
background: #0faf97;
color: #fff;
border-color: #fff;
}
.btn-primary:hover {
background: #fff;
color: #0faf97;
}
.container {
max-width: 1020px;
}
.nav-pills > li.active > a,
.nav-pills > li.active > a:hover,
.nav-pills > li.active > a:focus {
background: #0faf97;
}
.jumbotron {
text-align: center;
border-bottom: 1px solid #e5e5e5;
padding-top: 90px;
padding-bottom: 90px;
color: #fff;
}
footer {
padding-top: 19px;
color: #777;
border-top: 1px solid #e5e5e5;
}
.block {
border:#ccc solid 1px;
padding: 20px 20px 30px 20px;
text-align: center;
}
.block h2 {
color: #0faf97;
}
.fa {
color: #0faf97;
}
.fa-3 {
font-size: 4em !important;
}
.marketing {
margin: 40px 0;
}
.content-region-1 {
background: #0faf97;
color: #ffffff;
text-align: center;
}
.content-region-2 {
background: #f4f4f4;
color: #333333;
}
.content-region-3 {
background: #000000;
color: #ffffff;
}
.content-region-2 img {
width: 100%;
}
.content-region-3 h4 {
}
.content-region-1 h1, .content-region-2 h3 {
margin: 0;
padding: 0;
padding-bottom: 15px;
font-size: 40px;
}
.content-region-3 form input[type="text"], .content-region-3 form textarea {
width: 100%;
padding: 5px;
background: #333;
color: #fff;
margin-bottom: 10px;
border: 0;
}
.pt20{padding-top: 20px;}
.pb20{padding-bottom: 20px;}
.pt30{padding-top: 30px;}
.pb30{padding-bottom: 30px;}
.pt40{padding-top: 40px;}
.pb40{padding-bottom: 40px;}
.pt50{padding-top: 50px;}
.pb50{padding-bottom: 50px;}
.pt60{padding-top: 60px;}
.pb60{padding-bottom: 60px;}
.side-widget {
margin-bottom: 40px;
}
.side-widget h3 {
border-left: 5px #0faf97 solid;
padding-left: 10px;
margin-bottom: 15px;
}
.title-bar {
background: #0faf97;
color: #ffffff;
padding-bottom: 10px;
border-bottom: 6px #ddd solid;
margin-bottom: 20px;
}
article.post {
border-bottom: 1px #ccc solid;
overflow: auto;
padding-bottom: 30px;
margin-bottom: 40px;
}
article.post .meta {
border-top: #ccc solid 1px;
border-bottom: #ccc solid 1px;
overflow: auto;
list-style: none;
margin: 0;
padding: 5px 0;
}
article.post .meta li {
float: left;
margin-right: 20px;
}
article.post img {
width:100%;
height: auto;
margin-bottom:20px;
}
.panel-heading {
background: #0faf97 !important;
color: #fff !important
}
.sidebar-widget ul {
padding: 0 !important;
list-style: none;
}
.sidebar-widget li {
position: relative;
display: block;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
}
.comments {
border: 1px #ccc solid;
padding: 10px;
margin-bottom: 20px;
margin-top: 10px;
}
.comments h2, .comments h3 {
background: #0faf97;
color: #fff;
padding: 5px;
}
.comment-body {
border: #ccc 1px solid;
margin-bottom:10px;
.comment-meta {
background: #333;
color: #fff;
padding: 10px;
overflow: auto;
}
.comment-meta img {
float: left;
margin-right: 10px;
}
.comment-meta time {
margin-left: 12px;
}
.comment-reply-link {
background: #0faf97;
color: #fff;
display: inline-block;
padding: 10px 15px;
}
.comment-form input, .comment-form textarea {
width: 100%;
padding: 3px;
border: #ccc 1px solid;
margin-bottom: 20px;
}
This is the comments.php file:
<div class="comments">
<h2>Comments</h2>
<?php $args = array(
'walker' => null,
'max_depth' => '',
'style' => 'ul',
'callback' => null,
'end-callback' => null,
'type' => 'all',
'reply_text' => 'Reply',
'page' => '',
'per_page' => '',
'avatar_size' => 80,
'reverse_top_level' => null,
'reverse_children' => '',
'format' => 'html5', // or 'xhtml' if no 'HTML5' theme support
'short_ping' => false, // #since 3.6
'echo' => true // boolean, default is true
);
?>
<?php wp_list_comments($args, $comments); ?>
<?php
$form_args = array(
'label_submit' => 'Send',
'title_reply' => 'Write a Reply or Comment',
'comment_notes_after' => '',
'comment_field' => '<p class="comment-form-comment"><label for="comment">'._x('Comment','noun').'</label><br /><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
);
comment_form($form_args);
?>
</div>
When I alter the article.post img css it also affects the avatar image. I can't figure out how to alter that behavior. The avatar image is way too big and I just want to make it thumbnail size.
Here is the single.php file:
<?php get_header(); ?>
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<article class="post">
<section class="row title-bar">
<div class="container">
<div class="col-md-12">
<h1><?php the_title(); ?></h1>
</div>
</div>
</section>
<section class="row main">
<div class="container">
<?php if(is_active_sidebar('sidebar')) : ?>
<div class="col-md-8">
<?php else : ?>
<div class="col-md-12">
<?php endif; ?>
<article class="post">
<div class="post_thumbnail">
<?php if(has_post_thumbnail()): ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<ul class="meta">
<li>By <?php the_author(); ?></li>
<li><?php the_time('F j, Y g:i a'); ?></li>
<li>
<?php
$categories = get_the_category();
$separator = ", ";
$output = '';
if($categories){
foreach($categories as $category){
$output .= ''.$category->cat_name .''.$separator;
//$output .= $category->cat_name . $separator;
}
}
echo trim($output, $separator);
?>
</li>
</ul>
<br>
<?php the_content(); ?>
</article>
<div class="clr"></div>
<?php endwhile; ?>
<?php endif; ?>
<?php comments_template(); ?>
</div>
<?php if(is_active_sidebar('sidebar')) : ?>
<div class="col-md-4">
<?php dynamic_sidebar('sidebar'); ?>
</div>
<?php endif; ?>
</div>
</section>
<?php if(is_active_sidebar('content-region-1')) : ?>
<?php dynamic_sidebar('content-region-1'); ?>
<?php endif; ?>
<?php if(is_active_sidebar('content-region-2')) : ?>
<?php dynamic_sidebar('content-region-2'); ?>
<?php endif; ?>
<?php get_footer(); ?>
When I alter article.post img it changes the avatar img in comment section, but it also alters the blog images. Not sure that ended up happening. In theory, if I had done this correctly, comment-meta img should be what alters the avatar image. Chrome developer tools outputs this as CSS:
element.style {
}
article.post img {
width: 100%;
height: auto;
margin-bottom: 20px;
}
.comment-meta img {
float: left;
margin-right: 10px;
}
img {
vertical-align: middle;
}
img {
border: 0;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
img[Attributes Style] {
height: 80px;
width: 80px;
}
Inherited from footer.comment-meta
.comment-meta {
background: #333;
color: #fff;
padding: 10px;
overflow: auto;
}
footer {
padding-top: 19px;
color: #777;
border-top: 1px solid #e5e5e5;
user agent stylesheet
li {
display: list-item;
text-align: -webkit-match-parent;
}
Inherited from body.post-template-default.single.single-post.postid-20.single-format-standard.logged-in.admin-bar.wp-custom-logo.customize-support
body {
padding-top: 20px;
font-size: 15px;
color: #7a7a7a;
line-height: 1.7em;
}
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333;
background-color: #fff;
}
Inherited from html
html {
font-size: 10px;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html {
font-family: sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
Pseudo ::before element
*:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Pseudo ::after element
*:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
The article.post img selector targets all images that are inside the article.post element. This includes your avatar images.
If you don't want to target the avatars, then make your selector more specific. Try this instead:
article.post .post_thumbnail img {
width: 100%;
height: auto;
margin-bottom: 20px;
}
Now, only images that are descendants of article.post and .post_thumbnail will get the styles.
revised fiddle

Bootstrap distorting the Border-Radius icon/image

So Im working on a project for a client and ran into an issue with Border-Radius + Bootstrap,
<div class="header">
<div class="top-nav">
<div class="container">
<div class="row">
<img class="logo" src="<?php if($custom_logo){echo $custom_logo; }else{echo $avatar;} ?>">
<nav class="social-media-top">
<h1 class="col-xs-12">Hello, I am <span><?php echo $twitch_username; ?></span></h1>
<?php if($twitch_username){ ?>
<li><i class="fa fa-twitch"></i></li>
This is after adding bootstrap to make it more responsive on mobile, well after doing that this is what the top now looks like;
This is what it looks like when I remove the Bootstrap code;
This is the code with out bootstrap on the image
<div class="header">
<div class="top-nav">
<div class="container">
<div class="row">
<img class="logo" src="<?php if($custom_logo){echo $custom_logo; }else{echo $avatar;} ?>">
<nav class="social-media-top">
<h1 class="col-xs-12">Hello, I am <span><?php echo $twitch_username; ?></span></h1>
<?php if($twitch_username){ ?>
<li><i class="fa fa-twitch"></i></li>
This is my css
/* Top Header */
.header {
padding-top: 1.5em;
border-top: solid .3em rgba(46, 204, 113, 1.0);
}
.top-nav {
margin-top: 1.2em;
margin-right: auto;
margin-bottom: .8em;
margin-left: auto;
width: 30em;
}
.logo {
float: left;
width: 5em;
height: 5em;
border: solid .1em rgba(46, 204, 113, 1.0);
border-radius: 50%;
}
.social-media-top {
float: right;
padding-bottom: 1em;
}
.social-media-top h1 {
margin: 0;
padding: 0;
color: #41eb71;
font-weight: 100;
font-size: 2em;
align-content: center;
}
.social-media-top h1 span {
color: #41eb71;
text-transform: capitalize;
font-weight: 600;
}
.social-media-top li {
display: inline-block;
}
.social-media-top li i {
display: inline-block;
width: 2em;
height: 2em;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background-color: rgba(46, 204, 113, 1.0);
color: white;
text-align: center;
line-height: 2em;
}

Splitting echo row results into 3 separate columns (divs)

I have made this gallery listview page here and I want it so that all 3 columns are equally filled with items from my database, right now it creates a new column every time and displays the same sql item thrice.
Img here: http://i.stack.imgur.com/LMw1L.png
As you can see it just creates a whole bunch of columns which is not what I want.
How do I alter my php so that it neatly distributes the database items in my 3 columns (.column, .column-2, .column-3)?
home.php
<?php
ob_start();
require_once("connect.php");
if(isset($_POST['name'])){
$_SESSION["user"] = $_POST["name"];
$name = $_SESSION["user"];
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/dotbar.css">
<link rel="stylesheet" href="css/loginoverlay.css">
<!--jQuery library voor de menubar -->
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<meta charset="utf-8">
</head>
<body>
<!-- Show login screen, when cookie is not placed -->
<?php
if (empty($_COOKIE['first_time'])) {
?><div id="black-overlay">
<div id="grey-box">
<span id='close' onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;'>x</span>
<form action="home.php" method="POST">
<br>
<br>
<label for="name"> Naam: </label>
<br>
<input type="text" name="name" id="name">
<label for="password"> Wachtwoord: </label>
<br>
<input type="password" name="password" id="password">
<input type="submit" value="submit" name="submit">
</form>
</div>
</div><?php;
setcookie("first_time", 1, time()+157680000); /* expire in 5 years */}
?>
<!--page content -->
<div class="container">
<div class="container2">
<nav id='nav_bar'>
<ul class='nav_links'>
<li>
<?php
//If there is a user SESSION echo in NAV bar
if(isset($_SESSION['user'])) {
//echo admin link when admin is logged in
if ($_SESSION['user'] == 'admin') {
echo "<a href='admin.php'>Admin</a>";
echo "/<br>";
echo "<a href='sessiondestroy.php'>Log uit</a>";}
//echo user which is not the admin when logged in
else {echo $_SESSION["user"];
echo "/<br>";
echo "<a href='sessiondestroy.php'>Log uit</a>";}}
//echo the login button when user is not logged in
else { echo "<a href='login.php'>Login</a>";}
?>
<br><br><br>→<br><br><br>
</li>
<li>
<a href="?pages=home">
Home<br><br><br>→<br><br><br>
</a>
</li>
<li>
<a href="?pages=news">
Blog<br><br><br>→<br><br><br>
</a>
</li>
<li>
<a href="?pages=news2">
Gallery <br><br><br>→ <br><br><br>
</a>
</li>
<li>
<a href="?pages=news3">
About <br><br><br>→ <br><br><br>
</a>
</li>
<li>
<a href="?pages=news4">
Contact<br><br><br>→<br><br><br>
</a>
</li>
</ul>
</nav>
<div class="content">
<h1>
GRAKA!
</h1>
<div id="bar2">
<div id="circle1"></div>
<div id="circle2"></div>
<div id="circle3"></div>
<div id="circle4"></div>
<div id="circle5"></div>
<div id="circle6"></div>
<div id="circle7"></div>
<div id="circle8"></div>
<div id="circle9"></div>
<div id="circle10"></div>
<div id="circle11"></div>
</div>
<?php
if(isset($_GET['pages'])) {
$pages = $_GET['pages'];
$pagename = $pages. '.php';
include_once($pagename);
}?>
</div>
</div>
</div>
<footer>
<div class="footer-content">
<h2>
Designed and produced by
</h2>
<h3>
All rights reserved.<br>
</h3>
</div>
</footer>
<!--Menubar script -->
<script src="menubar.js"></script>
</body>
</html>
<?php
ob_flush();
?>
news2.php
$query = "SELECT * FROM gallery";
$result = mysqli_query($con, $query);
$count = 0;
while ($row = mysqli_fetch_array($result)) {?>
<?php if($count % 3 == 0) {?>
<div class="column">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
</div>
<?php}?>
<div class="column2">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
</div>
<div class="column3">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
</div>
<?php } ?>
css:
body {
margin: 0px;
padding: 0px;
background-color: black;
background-attachment: fixed;
background-image: url(img/2560x2560bubbles.png);
background-size: cover;
font-family: "Segoe UI", 'Helvetica Neue';
}
.container {
margin-top: 520px;
box-shadow: 10px 10px 5px #888888;
-webkit-box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.75);
box-shadow: 0px 0px 30px 0px rgba(50, 50, 50, 0.75);
background-image: -moz-linear-gradient( 180deg, rgb(158, 158, 158) 0%, rgb(188, 188, 188) 10%, rgb(220, 220, 220) 22%, rgb(251, 251, 251) 50%, rgb(220, 220, 220) 78%, rgb(188, 188, 188) 90%, rgb(158, 158, 158) 100%);
background-image: -webkit-linear-gradient( 180deg, rgb(158, 158, 158) 0%, rgb(188, 188, 188) 10%, rgb(220, 220, 220) 22%, rgb(251, 251, 251) 50%, rgb(220, 220, 220) 78%, rgb(188, 188, 188) 90%, rgb(158, 158, 158) 100%);
background-image: -ms-linear-gradient( 180deg, rgb(158, 158, 158) 0%, rgb(188, 188, 188) 10%, rgb(220, 220, 220) 22%, rgb(251, 251, 251) 50%, rgb(220, 220, 220) 78%, rgb(188, 188, 188) 90%, rgb(158, 158, 158) 100%);
}
.container2 {
width: 1280px;
padding-bottom: 100px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
nav {
margin-left: 7.5%;
margin-top: 100px;
width: 10%;
float: left;
}
#nav_bar {}
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
margin-left: 5.3%;
}
ul {
list-style-type: none;
}
li {
float: left;
font-size: 1em;
width: 100%;
height: auto;
text-align: left;
font-weight: bold;
line-height: 1em;
margin-left: 0%;
margin-top: 0px;
clear: none;
min-height: 0px;
}
a {
text-decoration: none;
color: black;
}
a:visited {
text-decoration: none;
color: black;
}
a:hover {
text-decoration: none;
color: grey;
}
a:focus {
text-decoration: none;
color: yellowgreen;
}
a:active {
text-decoration: none;
color: greenyellow
}
.content {
width: 70%;
margin-right: 7.5%;
margin-top: 100px;
float: right;
}
article {
width: 45.4%;
padding: 2.3%;
float: left;
}
img {
width: 100%;
}
h1 {
text-align: right;
margin: 0px;
font-size: 6.0em;
margin-bottom: 10px;
}
h2 {
margin: 0px;
text-align: center;
}
h3 {
margin: 0px;
text-align: center;
}
p {}
p1 {
float: right;
}
footer {
margin-top: 320px;
background-color: rgb(28, 28, 28);
height: 260px;
padding: 120px;
}
.footer-content {
color: white;
}
/*--Bloglist.css --*/
#blog {
width: 100%;
padding: 2.3%;
margin-top: 2.3%;
overflow: hidden;
}
article3 {
width: 100%;
padding: 2.3%;
overflow: hidden;
}
#blogfoto {
width: 257px;
height: 257px;
float: left;
overflow: hidden;
background-color: black;
}
p1#blog {
margin-top: 0px;
width: 62.07%;
float: left;
}
h4 {
margin-left: 2.3%;
float: left;
width: 56.66%;
margin-bottom: 0px;
}
/*-- Thumbnails --*/
.wrapper {
width: 400px;
height: 200px;
overflow: hidden;
background-size: cover;
}
/*-- Gallerylist -- */
.column {
float: left;
margin-left: 0px;
margin-top: 20px;
width: 28.73%;
padding: 2.3%;
background-color: blue;
}
.column2 {
float: left;
margin-left: 0px;
margin-top: 20px;
width: 28.73%;
padding: 2.3%;
background-color: green;
}
.column3 {
float: left;
margin-left: 0px;
margin-top: 20px;
width: 28.73%;
padding: 2.3%;
background-color: red;
}
I'm assuming that you want each column to show a different row from your database. If so, just include a counter variable say $count = 0; before you enter your loop.
When $count % 3 == 0 use the class '.column', when $count % 3 == 1 use the '.column-2' and $count % 3 == 2 use '.column-3'.
Don't forget to increment the loop counter at the end of each iteration.
Edit:
<?php
$query = "SELECT * FROM gallery";
$result = mysqli_query($con, $query);
$count = 0;
while ($row = mysqli_fetch_array($result)) {?>
<?php if($count % 3 == 0) {?>
<div class="column">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
<?php }
else if($count % 3 == 1){
?>
</div>
<div class="column2">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
</div>
<?php }
else{
?>
<div class="column3">
<div style="width: 100%; height: 0; padding-bottom: 100%; background-image:url('img/<?php
echo "".$row['galleryfoto']."";
?>'); background-repeat:no-repeat; background-size:cover; background-color: black; float:left; background-position: center;"></div>
<h4><?php echo $row['gallerytitel']?></h4>
</div>
<?php
}
$count++;
}
?>
This is not the neatest code, but this should get the job done.

Categories