I am working on a WordPress site and developing the blog posts page. I have set it up so you have the posts on the left and the sidebar on the right. But I have placed the sidebar code at the top of the page with logic to determine which side the users wants the sidebar.
The problem I was trying to solve was if the sidebar code is at the top in mobile devices it will be shown before the blog posts. So I found a method that uses table features to help resolves this. This works fine for all pages except the blog posts, when I resize, the thumbnail image is shown at it's full size despite me constraining it to the max width of the container.
PHP/HTML:
<?php get_header(); ?>
<div class="wrapper">
<?php if ( get_theme_mod( 'realestatepro_sidebar_position', esc_attr__( 'right', 'realestatepro' ) ) == "left" )
{ echo '<div class="col-xs-12 col-sm-3 col-md-3 sidebar left-sidebar">'; }
else
{ echo '<div class="col-xs-12 col-sm-3 col-md-3 sidebar right-sidebar">'; }
?>
<?php get_sidebar(); ?>
</div>
<div class="col-xs-12 col-sm-9 col-md-9 feature">
<div class="col-xs-12 col-sm-12 col-md-12 blog-article">
<?php
if( have_posts() ):
while( have_posts() ): the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="col-xs-12 col-sm-12 col-md-12">
<?php the_title('<h3 class="entry-title">','</h3>' ); ?>
<small>Post in:<?php the_category(' '); ?>, by <?php the_author_link(); ?> on <?php the_time('F jS, Y'); ?></small>
</div>
<?php if( has_post_thumbnail() ): ?>
<div class="col-xs-12 col-sm-12 col-md-12">
<?php the_post_thumbnail('full'); ?>
</div>
<?php endif; ?>
<div class="col-xs-12 col-sm-12 col-md-12">
<?php the_content(); ?>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<hr>
<div class="col-xs-6 text-left"><?php previous_post_link(); ?></div>
<div class="col-xs-6 text-right"><?php next_post_link(); ?></div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<hr>
<?php
if( comments_open() ){
comments_template();
}
?>
</div>
</article>
<?php endwhile;
endif;
?>
</div>
</div>
</div>
<?php get_footer(); ?>
CSS:
.blog-article img {
height: auto;
max-width: 100%;
margin: 10px 0px;
}
.left-sidebar {
float: left;
}
.right-sidebar {
float: right;
}
#media (max-width: 767px) {
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
float: none;
}
.wrapper {
display: table;
float: right;
}
.sidebar {
display: table-footer-group;
}
.feature {
display: table-header-group;
}
}
You could try the fixed table layout:
.wrapper {
display: table;
width: 100%; /*added*/
table-layout: fixed; /*added*/
}
Of course, the image should be set as:
img {
max-width: 100%;
height: auto;
}
https://jsfiddle.net/n7bpz5sj/1/
The proper way to do layouts where you need to change the ordering of divs is with flexbox using the order property. In your case, the responsive layout would look something like this:
.wrapper {
display: flex;
flex-direction: column;
}
.sidebar {
order: 2;
}
.feature {
order: 1;
}
Related
my 'about me' and echoed 'about text' appear below the containing div(class="u-about"), for both of them, i have no idea why its doing this, and id rather not use relative positioning to move it up, as it seems messy, and it shouldn't be doing this in the first place. any idea's on how to fix this would be much appreciated!
my css code:
.profile-about { /* contains profile card and about card */
float: left;
}
.u-about {
position: relative;
top: 100px;
display: block;
width: 400px;
height: 220px;
background-color: white;
border-radius: 10px;
text-align: center;
margin: 0px;
}
.ubout {
margin: 0px;
}
my html code:
<section>
<div>
<div class="profile-about">
<div class="u-profile-card">
<h3>Guide:</h3>
<div>
<h2><?php echo ucfirst($first);?> <?php echo $last; ?></h2>
</div>
<div class="img-txt">
<div class="image-cropper">
<img class="u-image" src="uploads/<?php echo $image; ?>" alt="no
image found">
</div>
<div class="u-info">
<h2><?php echo ucfirst($u_city); ?>, <?php echo ucfirst($u_region); ?
>, <?php echo ucfirst($u_country); ?></h2>
<h2><?php echo ucfirst($u_rating); ?> Stars</h2>
<h2 class="u-email"><?php echo ucfirst($email); ?></h2>
</div>
</div>
</div>
<div class="u-about">
<div>
<h1>About me</h1>
<p class="ubout"><?php echo ucfirst($about); ?></p>
</div>
</div>
</div>
By the containing div, I assume you mean their direct parent <div class="u-about">. The elements do not actually appear below that... though they may well appear to, due to the fact that you have top: 100px on this element. Simply removing this will bring the entire .u-about element up the page, including both texts:
.profile-about {
/* contains profile card and about card */
float: left;
}
.u-about {
position: relative;
/*top: 100px;*/
display: block;
width: 400px;
height: 220px;
background-color: white;
border-radius: 10px;
text-align: center;
margin: 0px;
}
.ubout {
margin: 0px;
position: relative;
bottom: 200px;
}
<section>
<div>
<div class="profile-about">
<div class="u-profile-card">
<h3>Guide:</h3>
<div>
<h2>
<?php echo ucfirst($first);?>
<?php echo $last; ?>
</h2>
</div>
<div class="img-txt">
<div class="image-cropper">
<img class="u-image" src="uploads/<?php echo $image; ?>" alt="no
image found">
</div>
<div class="u-info">
<h2>
<?php echo ucfirst($u_city); ?>,
<?php echo ucfirst($u_region); ?
>, <?php echo ucfirst($u_country); ?>
</h2>
<h2>
<?php echo ucfirst($u_rating); ?> Stars</h2>
<h2 class="u-email">
<?php echo ucfirst($email); ?>
</h2>
</div>
</div>
</div>
<div class="u-about">
<div>
<h1>About me</h1>
<p class="ubout">
<?php echo ucfirst($about); ?>
</p>
</div>
</div>
</div>
</div>
</section>
Try this:-
.profile-about { /* contains profile card and about card */
float: left;
}
.u-about {
position: relative;
display: block;
top:100px;
width: 400px;
height: 220px;
background-color: white;
border-radius: 10px;
text-align: center;
margin: 0px;
}
.ubout {
margin: 0px;
position: relative;
bottom: 200px;
}
.child{
position: absolute;
height: 320pxpx;
margin: -100px 0 0 0px;
}
<section>
<div>
<div class="profile-about">
<div class="u-profile-card">
<h3>Guide:</h3>
<div>
<h2><?php echo ucfirst($first);?> <?php echo $last; ?></h2>
</div>
<div class="img-txt">
<div class="image-cropper">
<img class="u-image" src="uploads/<?php echo $image; ?>" alt="no
image found">
</div>
<div class="u-info">
<h2><?php echo ucfirst($u_city); ?>, <?php echo ucfirst($u_region); ?
>, <?php echo ucfirst($u_country); ?></h2>
<h2><?php echo ucfirst($u_rating); ?> Stars</h2>
<h2 class="u-email"><?php echo ucfirst($email); ?></h2>
</div>
</div>
</div>
<div class="u-about" style="background-color:red;">
<div class="child">
<h1>About me</h1>
<p class="ubout"><?php echo ucfirst($about); ?></p>
</div>
</div>
</div>
I am making a invoice generate web application. invoice is design with div, and row & cell are also border lined div.
All is good in the screen but when i send invoice to print, all the bottom border line are stack up in first page which are to be in second page, weird part is this only happens in second page only.
How can I fix this??
Here is HTML code for each row this keep looping for max number of rows needed.
<div class="container_24">
<div id="invoice_frame" class="grid_18" style="padding:0px;">
<?php for ($x = 1; $x <= 60; $x++) {
<!-- Row Box <?php echo $x ?> -->
<div class="rowBox rowBox-<?php echo $x ?> ti_box_WO_bottom" data-id="1" style="width:705px;">
<div class="ti_box_onlyRight"> </div>
<div class="ti_box_onlyRight"> </div>
<div class="ti_box_onlyRight" style="width:378px;" align="left"> </div>
<div class="ti_box_onlyRight"> </div>
<div style="margin:0px; margin-right:3px;"> </div>
</div>
<?php } ?>
<div class="ti_line"> </div>
<div>
<div style="width:592px;" align="right"><strong>Total: </strong></div>
<div class="ti_box" style="width:113px;" align="center"><?php echo $TInvoice_ROW['total_amount']; ?></div>
</div>
<div>
<div style="width:592px;" align="right"><strong>Tax(GST) 6%: </strong></div>
<div class="ti_box" style="width:113px;" align="center"><?php echo $TInvoice_ROW['gst_amount']; ?></div>
</div>
<div>
<div style="width:592px;" align="right"><strong>Grand Total: </strong></div>
<div class="ti_box pv_total_box" style="width:113px; margin:0px;"><?php echo $TInvoice_ROW['total_grand']; ?></div>
</div>
<div>
<div style="padding-top:6px;" align="right"><strong>Amount in words: </strong></div>
<div style="width:559px; vertical-align:text-bottom; margin:0px;" align="left">
<textarea name="inwords" disabled="disabled" readonly class="pv_textbox_WO_outline" id="inwords" style="width:580px;"></textarea>
</div>
</div>
</div>
</div>
Here is CSS
.container_24 {
margin-left: auto;
margin-right: auto;
width: 960px;
}
#invoice_frame {
margin: 5px;
background-color: #FFF;
padding: 20px;
}
#invoice_frame div{
display: inline-block;
float: left;
}
#invoice_frame div.ti_box_onlyRight {
border-right-width: 1px;
border-right-style: solid;
border-right-color: #000;
margin:0px !important;
}
#invoice_frame div.ti_box_WO_bottom {
border: 1px solid #000;
border-bottom: none !important;
}
I have a problem in making my div row centered, i have 3 posts from wordpress which is equivalent to 3 columns inside the row, but it didn't centered after i add many css attributes to let it center. I am also using wordpress.
Here is my code :
<div class="row center-block">
<?php while ( $offerBlog->have_posts() ) : $offerBlog->the_post(); ?>
<div class="col-md-4 ">
<img src="<?php the_field('offer_image') ?>">
<br>
<br>
<h4><?php the_field('offer_title') ?></h4>
<?php the_field('offer_description') ?>
</div>
<?php endwhile; ?>
</div>
Here is my CSS:
.col-md-4 {
width:15%;
margin:0 2.5%;
text-align: center
}
.center-block {
margin-left:auto;
margin-right:auto;
display:center;
}
Try this:
Check demo HERE
CSS:
.center-block {
display: flex;
flex-direction: row;
justify-content: center;
}
I hope it helps
I got a couple of col-sm-6 divs for a page. I use the_post_thumbnail() to get the page featured image and put it in the first col-sm-6 column but the image breaks out the column.
I could use "medium" as a parameter but I would like the image to fit that column width automatically.
How can I get it?
<div class="row">
<div class="col-sm-6 page-frame">
<h1 class="blog-post-title"><?php the_title(); ?></h1>
<?php if( has_post_thumbnail() ) the_post_thumbnail( 'full' ); ?>
</div><!-- col-sm-6 -->
<div class="col-sm-6 page-frame">
<?php the_content(); ?>
</div><!-- col-sm-6 -->
Sounds like you are on the right track, in your css you would probably just do a max-width: 100%; or a min-width: 100%;
I'm creating a one-page WordPress-theme. In each section there is a header with an image and an overlay.
The header has a background, within there is an image of a wrap-width. on bottom of that, there is a png-image which is semi-transparent and should be full-width, overlaying the header-image.
Since I'm using different styling for the sections, I'm numbering them and the overlay-image is in a different color for each section. So I should insert it through CSS.
Until now I just could make the overlay visible when I type in a height value. But since the page needs to be responsive, I want the height to be variable, and always 100% width.
My Code:
<?php query_posts('post_type=page&order=ASC'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="content" class=" section-<?php echo $i++; ?>">
<h2 class="headline"><?php the_field('headline') ?></h2>
<div class="header">
<div class="wrap cf">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('bones-thumb-600');
}
else {
}
?>
</div>
<div class="overlay"></div>
</div>
<div id="inner-content" class="wrap cf">
<div id="main" class="m-all">
<div class="stripes"></div>
<!-- Thumbnail -->
<a class="logo" href="#top"><img src="<?php echo get_template_directory_uri(); ?>/library/images/logo.png" /></a>
<div class="sidebar">
<?php the_field('sidebar') ?>
</div>
<div class="main-content"><?php the_content(); ?></div>
<img src="<?php echo get_template_directory_uri(); ?>/library/images/separator.svg"/>
</div>
</div>
opacity: 0.5; should be what you search, 0.0 is transparent and 1.0 is visible, so 0.5 would be 50% visible
Please do like this
.image-holder{
height: 200px;
width:200px;
position: relative;
}
.image-holder:after{
content:'';
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background: rgba(0,0,0,.3);
}
<div class="image-holder"><img src="images/img02.jpg" height="371" width="556" alt="image description"></div>