CSS - how to fix text appearing below containing div box? - html

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>

Related

How to align two elements on the same line from PHP

Screenshots:
Inspect element shows:
The "7 in stock" i want to align with the "10" bellow
I would like to align two $elements to display on the same line.
<span class="max">
<?php echo $tickets_sold, $max_tickets; ?>
</span>
When the $tickets_sold is not included, the $max_tickets goes on the top. But when it's included, it immediately goes on the next line.
I've tried many different options as &&, and, but they never appear on the same line. I am sure the solution is easy, but I am a beginner.
$max_tickets = $product->get_max_tickets();
$tickets_sold = wc_get_stock_html( $product );
PHP code
<div class="wcl-progress-meter <?php if($product->is_max_tickets_met()) echo 'full' ?>">
<progress max="<?php echo $max_tickets ?>" value="<?php echo $lottery_participants_count ?>" low="<?php echo $min_tickets ?>"></progress></br>
<span class="zero">0 </span>
<span class="max"> <?php echo $tickets_sold, $max_tickets?></div></span>
</div>
CSS file
.wcl-progress-meter meter::-webkit-meter-suboptimum-value {
box-shadow: 0 5px 5px -5px #999 inset;
background: #cb132b;
display:inline-block;
}
.wcl-progress-meter .zero {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .min {
display: inline-block;
position: absolute;
top: -100%;
}
.wcl-progress-meter .max {
display: inline-block;
position: absolute;
top: -100%;
right: 0;
vertical-align: middle;
}
Just tweak your HTML a bit and all should work as you desire:
<style>
.flex-parent{display:flex;}
.flex-child{flex-basis:content;margin-right:10px;}
</style>
<div class="max flex-parent">
<div class="flex-child"><?php echo $tickets_sold;?></div>
<div class="flex-child"><?php echo $max_tickets;?></div>
</div>
<style>
.flex-parent{display:flex;}
.flex-child{flex-basis:content;margin-right:10px;}
</style>
<div class="max flex-parent">
<div class="flex-child">tickets_sold</div>
<div class="flex-child">max_tickets</div>
</div>
Or, you could also just use display:inline:
<style>
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
<style>
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max">
<div class="inline-block">tickets_sold</div>
<div class="inline-block">max_tickets</div>
</div>
Update:
Note the change to the first example code - I neglected to add the flex-parent class (a className I invented, not a convention) to the .max div.
To center the items in the parent, add justify-content:center; to the parent:
<style>
.flex-parent{display:flex;}
.flex-child{flex-basis:content;margin-right:10px;justify-content:center;}
</style>
<div class="max flex-parent">
<div class="flex-child"><?php echo $tickets_sold;?></div>
<div class="flex-child"><?php echo $max_tickets;?></div>
</div>
Using the display:inline-block method:
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block"><?php echo $tickets_sold;?></div>
<div class="inline-block"><?php echo $max_tickets;?></div>
</div>
<style>
.inline-parent{text-align:center;}
.inline-block{display:inline-block;margin-right:10px;}
</style>
<div class="max inline-parent">
<div class="inline-block">tickets_sold</div>
<div class="inline-block">max_tickets</div>
</div>

Why is div bottom-border not showing in print out?

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;
}

3 Column structure where the 2 outer columns are being dragged to the bottom of screen

I have a 3 col set up and when the page loads the two outer columns get pushed to the bottom of the screen. I can't move them using margins and believe it may be related to the center column which imports an external feed. I've spent hours on this with no resolution in sight. Any help would be extremely grateful for. webpage http://carrickswan.com/fix-test/
Sorry about the inline css it makes it look messy but hopefully someone can see the issue from the live page.
<!-- col 1 -->
<div style="background-color: white; width: 18%; margin: 25px 20px 0px 40px; display:inline-block;">
<div>
<h2 style="width: inherit; color: white; background-color: #2e2d2d; padding: 5px; background-image: url('http://carrickswan.com/wp-content/uploads/2016/04/header-bg2.png');
background-repeat: no-repeat;
background-position: right;" class="col-title">PLAY ONLINE</h2>
<img src="http://carrickswan.com/wp- content/uploads/2016/04/pay.jpg" alt="play swan lotto">
</div>
<div>
<h2>MEMBERSHIP</h2>
<img src="http://carrickswan.com/wp-content/uploads/2016/04/membership.jpg" alt="pay swan membership">
</div>
</div>
<!-- col 2 -->
<div id="content" style="background-color: white; width: 50%; display:inline-block; margin: 25px;">
<div id="content_fixtures"></div>
</div>
<!-- col 3 -->
<div style="width: 18%; display: inline-block; margin-top: 0px; background-color: white;">
<h2 class="title" style="color:white; background-color: #2e2d2d; padding: 5px; background-image: url('http://carrickswan.com/wp- content/uploads/2016/04/header-bg2.png'); background-repeat: no-repeat;
background-position: right;">LOTTO</h2>
<?php $cat_id = 7; //the certain category ID
$latest_cat_post = new WP_Query( array('posts_per_page' => 1, 'category__in' => array($cat_id)));
if( $latest_cat_post->have_posts() ) : while( $latest_cat_post->have_posts() ) : $latest_cat_post->the_post(); ?>
<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?></a></h2>
<div style="padding:5px;">
<?php the_content($more_link_text,$strip_teaser); ?>
Read More
</div>
<?php endwhile; endif; ?>
</div>
Add vertical-align: top; to the two outer divs - I tried it on your page and it worked.
if you don't want to make them align top
here is the solution
wrap your 3 divs within container
<div class="main-container">
<div class="column one">
<div class="column two">
<div class="column three">
</div>
CSS
.main-container
{
display:flex;
}
.main-container .column
{
flex:1;
}

CSS table arrange elements order but image no longer responsive

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;
}

Create semi-transparent Image Overlay

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>