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;
}
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;
}
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.
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;
}
I want to center align logo image of my wordpress theme, I've tried to do so but failed;
Here's the CSS for Header Area
/* Header
-------------------------------------------------------------- */
.logo { float:left; width:370px; margin-bottom: 10px; }
.logo .logo-text { color:#595959; font-size:58px; line-height: 54px; font-family:Georgia; }
.logo .logo-text:hover { color:#575757; text-decoration: none;}
#search { float:left; width:235px; text-align: left; margin-bottom: 10px; }
#search #site-description { line-height: 11px; margin-bottom: 1px; font-size: 11px;}
#search input[type="text"] { width:190px; color:#828282; font-size:11px; padding-right: 30px; }
#search input:focus{ border: 1px solid #acacac;}
#search input[type="submit"] { color: #818181; }
#search input[type="submit"]:hover{ color: #FF4949; }
#search .button { margin-left:-30px; padding:0; border:none; background: none; }
#search .button span { color:#828282; background: none; text-transform: uppercase; }
#top-cart { text-align: right; float:right; position: relative; padding:1px 20px 5px 0; background: url(images/shopping-bag.png) no-repeat top right; width:280px; line-height: 16px;}
#top-cart > a{ color:#818181;}
#top-cart .mobile-link { display: none; position: absolute; width: 100%; height: 100%; text-indent: -9999em;}
#top-cart .dark-span .amount { color:#090909; font-size: 12px;}
#top-cart .cart-popup { display:none; width:295px; text-align: left; padding:20px 15px 15px 15px; border:1px solid #acacac; background: white url(images/line3.png) repeat-x top; position: absolute; z-index:10001; right:0; top:20px;}
#top-cart .cart-popup .empty { text-align: center;}
#top-cart .cart-popup .recently-added { font-size:10px; text-transform: uppercase;}
#top-cart .cart-popup .totals .amount, #top-cart .cart-popup .totals { font-family: Verdana; clear: both; padding:5px 0; margin-bottom: 10px; font-size:14px; text-transform: uppercase; text-align: right; color:#818181; }
#top-cart .cart-popup .totals .amount{ color:#090909; }
#top-cart .amount { font-size:14px; font-weight: normal; color:#FF4949;}
#top-cart .cart-popup .totals .price { font-size:14px; font-weight: normal; color:#090909;}
#top-cart .cart-popup .button { }
#links { text-align: right; float:right; width:280px; margin-top:3px; margin-bottom: 10px;}
.links li { padding:3px 0 3px 17px; background: url(images/link-divider.png) no-repeat center left; display:inline-block;}
.links li:first-child { background: none; }
.entry-title,.page-title { font-size:24px; font-weight:normal; padding-top: 5px;color: #090909 !important; }
.page-description { padding:40px 0; border:1px solid #efefef; border-right:0; border-left:0; margin:10px 0 30px 0; font-size:32px; line-height:40px; font-weight:normal; h1.notFound { font-size:48px; }
h1.notFound strong{ color: #FF4949 }
.error404 { padding:0 0 20px 0; }
I've tried text-align:center but failed to center align.
HTML Code:
<header id="header">
<div id="search">
<div id="site-description"><?php bloginfo( 'description' ); ?></div>
<?php get_search_form(); ?></div>
<div class="logo">
<?php $logoimg = etheme_get_option('logo'); ?>
<?php if($logoimg): ?>
<img src="<?php echo $logoimg ?>" alt="<?php bloginfo( 'description' ); ?>" />
<?php else: ?>
<?php bloginfo( 'name' ); ?>
<?php endif ;?></div>
<div class="cart-wrapper">
<?php if(class_exists('Commerce') && etheme_get_option('just_catalog')!=1 && etheme_get_option('cart_widget')): ?>
<a class="mobile-link" href="<?php echo wpsc_cart_item_url(); ?>"></a>
<div id="top-cart" class="shopping-cart-wrapper">
<?php get_template_part( 'cart_widget' ); ?></div>
<?php endif ;?>
<?php if(class_exists('-') && etheme_get_option('just_catalog')!=1 && etheme_get_option('cart_widget')): ?>
<?php global $c?>
<a class="mobile-link" href="<?php echo $c->cart->get_cart_url(); ?>"></a>
<div id="top-cart" class="shopping-cart-wrapper widget_shopping_cart">
<?php $cart_widget = new Cart(); $cart_widget->widget(); ?>
</div>
<?php endif ;?></a></div>
</header>
I need suggestions on how to center align the logo image.
Thanks
Regards
Remove the float and the make the width 100% for the logo class. That is if you want your logo to fill up the width of your page/container.
.login{
width:100%;
text-align:center;
margin-bottom:10px;
}
If you have other elements/divs on either side of the logo, then you will need to calculate the width of the logo container, and do a text-align:center.
Can you provide your site URL, I have to see on site how the logo is aligned.
Normally what you need to do is split all menu items(ul>li) by two. Lets assume you have 6 Menus, to do so, align the first item to more left and then shift the 4th Menu more right, By this you will make space for the logo in the middle.
Now Shift your logo to the middle by css rule: left:10% (% will make it Responsive, you may also use 10px).
If you can provide site url, i can provide you exact rule.
Hi i have coded my news content of my wordpress blog, i made the content float right and the date and comments float left of the conten, now it is floating perfectly except for one thing.
The date and comments for the first post is aligned but the date and comments for the second post is also aligned with the first post, when it should be aligned with the second post. and the date and comments under the second post is suppose to be for the third post, which leaves the last post without date time or comments. Example below.
here is my css
#content {
width: 1070px;
}
.right{
position:relative;
float:right;
right:215px;
}
.left{
position:relative;
float:left;
left:200px;
display:block;
}
.date{
width:80px;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
clear:left;
}
.month {
color:#fff;
font-size:15px;
font-family:eurofurence;
text-transform:uppercase;
}
.year {
color:#fff;
padding:0 0 7px 0;
font-size:30px;
font-family:eurofurence;
text-transform:uppercase;
}
.commentbubble{
background: url('http://bleedartmedia.com/mock/wp-content/themes/KellyRowland/images/commentb.png') no-repeat;
width:40px;
height:49px;
padding:4px 0 0 14px;
}
.entry {
margin: 0px 0px 0px 0px;
padding: 0px 10px 0px 10px;
border-bottom: 0px solid #cccccc;
font-family:eurofurence;
font-size:17px;
width:610px;
background:#000;
}
.entry-top {
margin: 0 0 0px 0;
padding: 0 0 0px 0;
text-align: left;
}
.entry-top .entry-title {
color: #fff;
font-family:eurofurence light;
font-size:28px;
}
.entry-top .entry-author {
font-style: italic;
}
.entry-title {
margin: 0;
padding: 0;
font-size: 1.3em;
font-weight: bold;
line-height: normal;
font-stretch: narrower;
}
.entry-title a:link,
.entry-title a:visited {
color: #fff;
font-family:eurofurence light;
font-size:28px;
}
.entry-title a:hover {
color: #3E7AB9;
text-decoration: none;
}
.entry-content {
margin: 10px 0 10px 0;
padding: 0px 10px 10px 10px;
font-family:eurofurence;
font-size:17px;
}
and here is my coding
<div id="content">
<?php while ( have_posts() ) : the_post() ?>
<div class="date left">
<div class='month'><?php the_date('M');?></div>
<div class='year'><?php the_time('d');?></div>
<div class="commentbubble">
<?php comments_popup_link( __( '0', 'wpbx' ), __( '1', 'wpbx' ), __( '%', 'wpbx' ) ) ?>
</div>
Comments
</div>
<div class="entry right">
<div class="entry-top">
<h2 class="entry-title"><?php the_title() ?></h2>
</div>
<div class="entry-content clearfix">
<div class="entry-content">
<div id="text"><?php the_content() ?></div>
</div>
</div>
<div class="entry-meta">
</div>
</div><!-- .post -->
<br>
<?php endwhile; ?>
</div><!-- #content -->
Anyone have a solution
I'm guessing your php while loop starts outside of the shown html? What I would do here is make sure that you contain your date-left and entry-right in a single div, and use the php while to repeat the div. I think all you'll have to do is find where your while loop starts, add a div, and then right before it ends add a closing div.
<loop start>
<div>
....(divs containing entry and date here)
</div>
<loop end>
Try adding this to clear the float:
.date.left { clear: left; }