I have a wordpress website (you can see the problem at duncanhill.com.au)
And if you look at the website, the first 3 property boxes align properly, however the 4th and 5th do some weird stuff.
The code looks like this:
HTML:
<div id="grid-gallery" class="grid-gallery">
<section class="grid-wrap">
<ul class="grid">
<li class="grid-sizer"></li><!-- for Masonry column width -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>">
<li>
<figure>
<div class="figimg"><?php the_post_thumbnail(); ?></div>
<figcaption><h3 class="figtitle"><?php the_title(); ?></h3><p class="price"><?php the_subtitle(); ?></p><p class="figdesc"><?php the_excerpt(); ?></p></figcaption>
</figure>
</li>
</a>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</ul>
</section><!-- // grid-wrap -->
CSS:
/* General style */
.grid-gallery ul {
list-style: none;
margin: 0;
padding: 0;
}
.grid-gallery figure {
margin: 0;
}
.grid-gallery figure img/*.figimg*/ {
display: block;
/*width: 100%;
height: 100%;*/
/*height: 210px;*/
border-top-right-radius: 5px;
border-top-left-radius:5px;
}
.grid-gallery figcaption h3 {
margin: 0;
padding: 0 0 0.5em;
}
.grid-gallery figcaption p {
margin: 0;
}
/* Grid style */
.grid-wrap {
max-width: 69em;
margin: 0 auto;
padding: 0 1em 1.875em;
}
.grid {
margin: 0 auto;
}
.grid li {
width: 33%;
float: left;
cursor: pointer;
}
.grid figure {
padding: 15px;
-webkit-transition: opacity 0.2s;
transition: opacity 0.2s;
}
.grid li:hover figure {
opacity: 0.7;
}
.grid figcaption {
font-family: 'lato';
font-weight: 300;
color: #000000;
padding: 25px;
border-left-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-width: 2px;
border-color: #4B91F0;
border-bottom-left-radius:5px;
border-bottom-right-radius:5px;
}
.figtitle{
font-family: 'lato';
font-weight: 400;
}
.figdesc{
}
.price{
font-weight: 400;
color: #E74C3C;
}
I really can't work out how to fix it!
Any help with aligning the boxes would be greatly appreciated!
Thanks,
Tom
There are two things you need to do to fix this issue, the first one having to do with the HTML you posted.
First, change your HTML code above so that the empty list item with the class of 'grid-sizer' is removed and your anchor tags within your loop are contained within the list items. It should look like this instead of what you currently have:
<div id="grid-gallery" class="grid-gallery">
<section class="grid-wrap">
<ul class="grid">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<figure>
<div class="figimg"><?php the_post_thumbnail(); ?></div>
<figcaption><h3 class="figtitle"><?php the_title(); ?></h3><p class="price"><?php the_subtitle(); ?></p><p class="figdesc"><?php the_excerpt(); ?></p></figcaption>
</figure>
</a>
</li>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</ul>
</section><!-- // grid-wrap -->
Second, add the following style to your css:
.grid :nth-child(3n+1) {
clear: left;
}
Related
I'm trying to make a list with people that have been stored in a mysql database, however only the first database item is styled properly and the others are out of place. I'm fairly new with css and I probably made a mistake in the while loop or positioning.
https://i.imgur.com/cKJqT6s.png
Image ^^
The code that I'm using is as followed:
<div id="adminsummary">
<div id="admintitel">
<p id="admintext">Admin Overview</p>
</div>
<?php
while ($row = mysqli_fetch_array($result)) {
$steamid = $row["steamid"];
$xml = simplexml_load_file("http://steamcommunity.com/profiles/$steamid/?xml=1");
if (!empty($xml)) {
$username = $xml->steamID;
}
?>
<div id="admin">
<img id="adminimg" src="<?php echo $steamprofile['avatarmedium']; ?>">
<p id="adminname"><?php echo $username; ?></p>
<!-- <p id="adminname"> SteamID: <?php echo $row["steamid"]; ?></p> -->
<p id="adminname"> Rank: <?php if ($row["rank"] == 1) {echo "SuperAdmin";} else {echo "Admin";} ?></p>
<hr id="hr2">
</div>
</div>
The stylesheet:
#adminsummary {
background: white;
margin-top: 5%;
height: 75%;
width: 25%;
margin-right: 5%;
float:right;
border-radius: 25px;
box-shadow: 10px 10px 77px -6px rgba(0,0,0,0.59);
}
#admintitel{
background: #343a40;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
#admintext{
color: white;
font-family: sans-serif;
font-weight: bold;
text-align: center;
padding: 25px;
}
#adminimg {
border-radius: 25px;
float: left;
margin-left: 25px;
}
#hr2 {
display: block;
margin-top: 25px;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#adminname {
text-align: left;
font-weight: bold;
margin-left: 25%;
font-family: sans-serif;
}
Thanks for taking the time to help me
Try putting classes instead of id in your divs and p inside the while loop.
IDs are unique in CSS, that explain why the first row is styled, not the others.
If you modify the HTML and remove the IDs within the loop you can use a combination of classes with child/sibling selectors to assign styles in a cleaner way
<!-- these IDs are OK as they are unique ( presumably ) -->
<div id="adminsummary">
<div id="admintitel">
<p id="admintext">Admin Overview</p>
</div>
<?php
while ($row = mysqli_fetch_array($result)) {
$steamid = $row["steamid"];
$xml = simplexml_load_file("http://steamcommunity.com/profiles/$steamid/?xml=1");
if (!empty($xml)) {
$username = $xml->steamID;
}
?>
<!-- use classes &/or sibling selectors for cleaner html ~ no duplicate IDs though -->
<div class="admin">
<img src="<?php echo $steamprofile['avatarmedium']; ?>">
<p><?php echo $username; ?></p>
<p> Rank: <?php if ($row["rank"] == 1) {echo "SuperAdmin";} else {echo "Admin";} ?></p>
<hr />
</div>
<?php
}//close loop
?>
</div>
the slightly modified CSS using child selectors to assign styles within the .admin code block
#adminsummary {
background: white;
margin-top: 5%;
height: 75%;
width: 25%;
margin-right: 5%;
float:right;
border-radius: 25px;
box-shadow: 10px 10px 77px -6px rgba(0,0,0,0.59);
}
#admintitel{
background: #343a40;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
}
#admintext{
color: white;
font-family: sans-serif;
font-weight: bold;
text-align: center;
padding: 25px;
}
#adminsummary .admin img {
border-radius: 25px;
float: left;
margin-left: 25px;
}
#adminsummary .admin hr {
display: block;
margin-top: 25px;
margin-bottom: 0.5em;
margin-left: auto;
margin-right: auto;
border-style: inset;
border-width: 1px;
}
#adminsummary .admin p {
text-align: left;
font-weight: bold;
margin-left: 25%;
font-family: sans-serif;
}
In my single wordpress posts I want to apply a padding of 100px to the left and right text. The problem is that when I apply it to .single .post-content the images also get a padding. However, I want all of the images on the posts pages to be set to 100%. Is there a way to separate the actual body text and the images? This seems like a fairly simple question. But I can't figure it out. Any help is appreciated.
single.php
<?php
get_header();
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<article class="post">
<?php $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="banner" style="background:url(<?php echo $featuredImage; ?>) no-repeat;"></div>
<?php wpb_set_post_views(get_the_ID()); ?>
<div class="post-info">
<h1 class="post-title"><?php the_title(); ?></h1>
<h2 class="post-date"><?php echo strip_tags(get_the_term_list( $post->ID, 'location', 'Location: ', ', ', ' • ' ));?><?php the_date('F m, Y'); ?></h2>
</div>
<div class="post-content"><?php the_content(); ?></div>
<div id="wrapper-footer"><div class="post-footer"><h1 class="post-footer-comment"><?php comments_popup_link ('No Comments', '1 Comment', '% Comments', 'post-footer-comment-count', 'none'); ?></h1><div class="share"><span>share</span> <?php get_template_part( 'share-buttons-post' ); ?></div></div>
<div class="post-footer-bloglovin"><h1>never miss a post</h1><h2>follow on email'</h2></div></div>
<?php get_template_part( 'prevandnextpost' ); ?>
<?php get_template_part( 'related-posts' ); ?>
<?php comments_template(); ?>
</article>
<?php endwhile;
else :
echo '<p>No content found</p>';
endif;
get_footer();
?>
css
.single .post-title,
.post-title a,
.post-title a:link, .post-title a:visited {
font-family: 'Questrial', sans-serif;
font-size:30px;
margin-left:6px;
margin: 0 auto;
color:#000000;
margin-bottom: 3px;
margin-top:30px;
}
.single .post-date {
font-family: 'Questrial', sans-serif;
font-size:13px;
margin-left:6px;
margin: 0 auto;
color:#000000;
}
.single .post-content {
text-decoration: none;
color: #000000;
display: block;
font-family: 'Crimson Text', serif;
font-size: 18px;
margin:0 auto;
margin-top: -50px;
padding-left:100px;
padding-right:100px;
}
.single .post-info {
background:#ffffff;
padding-left: 100px;
padding-right:100px;
max-width: 1865px;
background-position:center;
background-clip: content-box;
margin: 0 auto;
height:110px;
bottom:100px;
position: relative;
}
.single img {
max-width:100%;
padding: 0 0 0 0 !important;
height:auto;
}
You are adding the padding to this selector (which searches for .post-content inside of .single element):
.single .post-content
Try wrapping text inside a p tag:
.post-content p {
padding-left:100px;
padding-right:100px;
}
Example below:
.post-content {
text-decoration: none;
color: #000000;
display: block;
font-family: 'Crimson Text', serif;
font-size: 18px;
margin: 0 auto;
margin-top: 0px;
/* padding-left: 100px; */
/* padding-right: 100px; */
width: 300px;
border: 1px solid gray;
}
.post-content p {
padding-left: 100px;
padding-right: 100px;
}
<div class="post-content">
<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=300×100&w=300&h=100" />
<p>TEST CONTENT TEST CONTENT OTHER TEST CONTENT TEST LONGER WORD</p>
</div>
if you defined:
.single .post-content {
...
padding-left:100px;
padding-right:100px;
}
and images are inside of .post-content, then you need to state a following rule:
.single img {
max-width:100%;
padding: 0 0 0 0 !important;
height:auto;
margin-left: -100px;
margin-right: -100px;
}
I am currently trying to add padding to the heading of this container and for some reason it's not letting me add any padding to the left or right. The image below show what it looks like at the moment.
here is my code:
<?php
$feed = 'http://miletich2.blogspot.co.uk/feed/';
$rss = fetch_feed($feed);
?>
<div class="container">
<div class="clear">
<div class="right">
<div class="rss-container">
<div class="rss-heading">
<?php
$title = "Clashing With Life";
$description = 'This is a blog written by an autistic person for other autistic people about <br>some of the biggest issues in life, whether deplorable or marvelous.';
echo '<h3 class="text-center title">' . $title . '</h3>';
echo '<p class="text-center">' . $description . '</p>';
?>
</div>
<?php
if ( !is_wp_error($rss) ) :
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
if ($rss_items):
foreach ($rss_items as $item) :
$item_title = esc_attr( $item->get_title() );
$item_permalink = esc_url( $item->get_permalink() );
$item_post_date = $item->get_date( get_option('date_format') );
$item_excerpt = wp_trim_words( wp_strip_all_tags( $item->get_description(), true ), 50 );
echo sprintf('<div class="spacing">%s<div class="pull-right">%s</div><p>%s</p><hr></div>', $item_permalink, $item_title, $item_post_date, $item_excerpt);
endforeach;
endif;
endif;
?>
Here is my css:
.right{
float:right;
}
.rss-container{
max-width: 400px;
width: 100%;
margin: 25px auto;
background: #f4f4f4;
padding: 0 20px 0 20px;
}
.rss-heading {
background: #7ED321;
color: #000;
padding: 15px 30px;
border-radius: 6px 6px 0 0;
-webkit-border-radius: 6px 6px 0 0;
font-weight: bold;
}
.rss-heading p{
font-size:9px;
}
hr{
border-top: 1px solid #DCDCDC !important;
}
.article-head{
line-height: 2em;
font-family: Roboto Condensed;
font-weight: bold;
}
.clear{
clear:both;
}
.spacing a {
line-height: 2em;
font-size: 15px;
}
.pull-right{
line-height: 2em;
font-size: 15px;
}
h3.title {
font-family: Roboto Condensed !important;
font-weight: bold;
}
in .rss-container I added this: padding: 0 20px 0 20px;
and .rss-heading padding: 15px 30px; I tried to change 30px to another value since I just want it to change left and right and it continued to change top and bottom. Any help would be appreciated!
To change just the left and right padding values, you can't use the 'padding' shortcut. Explicitly specify:
padding-right: 30px;
padding-left: 30px;
That will leave top and bottom unchanged.
In Safari on an iPhone a .container div that is behind a navigation menu .div scrolls when I scroll within the menu div, even though the menu is overlayed on top of the content div.
This only happens on an iPhone and I am not sure if it is related to something I have heard of called overscroll?
HTML Nav
<button class="c-hamburger c-hamburger--htx">
<span>toggle menu</span>
</button>
<nav id="sidebar" class="nav-container">
<!--Menu icon-->
<!--Widget area-->
<?php if ( is_active_sidebar( 'home_left_1' ) ) : ?>
<div id="primary-sidebar" class="nav-container primary-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'home_left_1' ); ?>
</div><!-- #primary-sidebar -->
<?php endif; ?>
<!--Menu js-->
<script>
(function() {
"use strict";
var toggles = document.querySelectorAll(".c-hamburger");
for (var i = toggles.length - 1; i >= 0; i--) {
var toggle = toggles[i];
toggleHandler(toggle);
};
function toggleHandler(toggle) {
toggle.addEventListener( "click", function(e) {
e.preventDefault();
(this.classList.contains("is-active") === true) ? this.classList.remove("is-active") : this.classList.add("is-active");
});
}
})();
$('.c-hamburger').click( function() {
$("#sidebar").toggleClass("show");
} );
</script>
</nav>
HTML Main Index
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="main" class="content">
<div id="content" class="content-container">
<section>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<p><?php the_content(__('(more...)')); ?></p>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
</section>
</div>
</div>
<div id="delimiter"></div>
<?php get_footer(); ?>
CSS
Here is the content div that scrolls even when the nav div is opened over it on an iPhone
/* Content area
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.content {padding-left: 20rem;}
.content-container {
display: block;
margin: 0px auto;
max-width: 78rem;
text-align: left;
padding: 0 4rem 0 4rem;
}
.content-container section {padding: 1.25rem;}
Here is my CSS for the nav div, but keep in mind the the media query that I also included overwrite some of this CSS at the size where I am experiencing a problem
/* Nav
–––––––––––––––––––––––––––––––––––––––––––––––––– */
nav {
position: fixed;
width: 20rem;
text-align: center;
left: 0;
top: 0;
bottom: 0;
background-color: white;
opacity: 1;
overflow-y:auto;
padding-bottom: 4rem;
transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
-webkit-transition: opacity .3s ease-in-out;
z-index: 8;
}
/*hides sidebar for mobile breakpoints*/
nav.show {opacity: 1; pointer-events: all;}
nav .nav-container {
display: inline-block;
padding-top: 5rem;
width: 50%;
text-align: left;
}
Here is the media query for the size that has a full-screen menu:
/*xx small*/
#media (min-width: 0px) and (max-width: 600px) {
html {font-size: 10.5px;}
.content {padding-left: 0;}
.content-container {padding: 0 1.5rem 0 1.5rem;}
.c-hamburger {display: block;}
nav {height: 100%; pointer-events: none; opacity: 0; width: 100%;}
nav .nav-container {float: left; padding: 9rem 0 0 6rem;}
nav a {font-size: 1.83rem;}
nav #logo {height: 4rem; width: 4rem; margin-bottom: 4rem;}
p {font-size: 1.83rem; font-weight: 300; line-height: 2.7rem;}
p, h2 {width: 100%;}
h1 {padding-top: 8rem;}
/*give h2 intro some space*/
h2 + h3 {padding-top: 5rem;}
h2 + h4 {padding-top: 5rem;}
h2 + p {padding-top: 5rem;}
}
Thank you for any help!
You just have to put a fixed position to that div
or you can put the absolute position if you need a floating div on behalf of parent div
.content-container {
display: block;
margin: 0px auto;
max-width: 78rem;
text-align: left;
position:fixed;//absolute for floating
padding: 0 4rem 0 4rem;
}
I am trying to replicate the image box on this page
http://kvalixhu.digitalthinkersni.co.uk/termekek/plc-hmi/unitronics/
on this page on my blog where the blog posts show i thought all i needed was thumbnail arrow buts its not showing correct with the css i have in the file
<style>
.thumbnail-arrow { width: 28px; height: 28px; position: absolute; bottom: -9px; right: 20px; background-image: url(./images/sprite1.png); background-size: 4300%; background-position: 7.993% 82.292%; transition: all 0s ease-in-out; }
</style>
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
<div class="thumbnail-arrow"></div>
</div>
I wish to replecate the hover effect here but I cannot for life of me see where the orange is being applied on the product image in the first link and the arrow
That would be in your style.css on line 690.
/* Default Link Styles */
a { color: #333333; text-decoration: underline; line-height: inherit; }
a:hover, a:focus { color: #f87b06; text-decoration: none; }
a img { border: none; }
edit; and the arrow at line 1118.
.products a:hover .thumbnail-arrow {
background-position: 5.442% 82.292%;
transition: all 0s ease-in-out;