HTML date display alignment - html

I am designing a web page which has a list of dates appearing on below the other. I want to align the dates such that they line up perfectly below each other. I have tried using align but it didn't make a difference. I also tried putting a style tag but I got an error which said:
"Element "style" not allowed as child of element "div" in this context."
Here's the code of the page:
<div class="report-title">
<h1>Response Tracking Report</h1>
</div>
<div class="info">
<div style="width:93%;float:left;">
<p class="title">Project: </p>
<p class="value"><?php echo $response_data['project_name']; ?></p>
</div>
<div class="spacer"></div>
<div style="width:7%;float:left;">
<p class="value"><?php echo date("Y-m-d"); ?></p>
</div>
<div class="bottom"></div>
</div>
<div id='response-info' class='info'>
<div style='width:100%;'>
<p class='title'>Risk Statement: </p>
<p id='risk_statement' class='value'><?php echo $response_data['risk_statement']; ?></p>
<br/><br/>
</div>
<div style='width:24%;float:left;'>
<p class='title'>WBS: </p><p class='value'><?php echo $response_data['WBS']; ?></p>
<br/><br/>
<p class='title'>Date of Plan: </p><p class='value' ><?php echo $response_data['date_of_plan']; ?></p>
<br/><br/>
<p class='title'>Last Updated: </p><p class='value' ><?php echo $response_data['date_of_update']; ?></p>
<br/><br/>
<p class='title'>Planned Closure: </p><p class='value' ><?php echo $response_data['planned_closure']; ?></p>
</div>
<div class='spacer' style='width:1%;float:left;height:1px;'></div>
<div style='width:24%;float:left;'>
<p class='title'>Owner: </p><p class='value'><?php echo $response_data['owner']; ?></p>
<br/><br/>
<p class='title'>Cost: </p><p class='value'>$<?php echo round($response_data['cost']); ?></p>
<br/><br/>
<p class='title'>Release Progress: </p><p class='value'><?php echo $response_data['release_progress']; ?></p>
<br/><br/>
<p class='title'>Action: </p><p class='value'><?php echo $response_data['action']; ?></p>
</div>
<div class='spacer' style='width:1%;float:left;height:1px;'></div>
<div style='width:50%;float:left;'>
<p class='title'>Current Status: <br/> </p><p class='value'><?php echo $response_data['current_status']; ?></p>
<br/>
<br/>
<p class='title'>Action Plan: <br/> </p><p class='value'><?php echo $response_data['action_plan']; ?></p>
</div>
<div id='bottom' style='clear:both;width:100%'></div>
</div>
<div id="ResponseUpdateTableContainer" class="jTableContainer" style="width:100%;"></div>
</body>
How dates are displayed currently: http://imgur.com/UxbugwX
How I am trying to get them: http://imgur.com/mAgfRYO
I am new to html so please excuse my errors. All help is greatly appreciated.

To have those DIV'saligned, you need to give them the same width, the problem with this, is when you have dynamic text, and the length overflow your already specifyed width.
One solution, is emulate the native table style, with display property in your css
like this for example:
.table { display: table; }
.row { display: table-row; }
.cell { display: table-cell; }
Then, your html will have something similar to this markup:
<div class="table">
<div class="row">
<span class="cell title">WBS:</span>
<span class="cell value">1.1</span>
</div>
<div class="row">
<span class="cell title">Planned Closure:</span>
<span class="cell value">2014-07-18</span>
</div>
<div class="row">
<span class="cell title">Last Updated:</span>
<span class="cell value">2014-09-10</span>
</div>
<div class="row">
<span class="cell title">Date of Plan:</span>
<span class="cell value">2014-04-26</span>
</div>
</div>
jsFiddle example: http://jsfiddle.net/gmolop/csx10g64/

With this code the dates will be aligned:
HTML:
<div class="container">
<div class="title">Date of Plan:</div>
<div class="date">2014-04-26</div>
</div>
<div class="container">
<div class="title">Last Updated:</div>
<div class="date">2014-09-10</div>
</div>
<div class="container">
<div class="title">Planned Closure:</div>
<div class="date">2014-07-18</div>
</div>
CSS:
.container {
width: 600px;
}
.title {
width: 180px;
display: inline-block;
}
.date {
width: 180px;
display: inline-block;
}
You can see the result here: http://jsfiddle.net/ben220/fuzhvL54/
I hope it helps.

I was able to solve the problem using margin-left, adjusting it until the dates aligned.

Related

Can't change text-decoration

I need to change text-decoration to none on my preview text, but I can't do it. Perhaps I am using wrong selectors.
.content .main-content.single .post-content{
text-decoration: line-through;
}
<div class="content clearfix">xxx
<div class="main-content single">
<h1 class="post-title"><?php echo $post['title']; ?> </h1>
<div class="post-content">
<?php echo html_entity_decode($post['body']); ?>
xxx
</div>
</div>
</div>
Daniel is right by adding a comma it applies to all and additionally change the text-decoration: line-through; to text-decoration: none;
:)
<style>
.content, .main-content.single, .post-content{
text-decoration: none;
}
</style>
<div class="content clearfix">xxx
<div class="main-content single">
<h1 class="post-title"><?php echo $post['title']; ?> </h1>
<div class="post-content">
<?php echo html_entity_decode($post['body']); ?>
xxx
</div>
</div>
</div>

:nth-child (odd) not displaying as hoped

I have two pages with search results from the Search & Filter plugin, as i don't know how to build the query and loop myself.
http://staging.montra.dk/tilbud & http://staging.montra.dk/events
I want the results to look just like my blocks on the rest of the site; image on one side - text on the other, and then reverse that in the next row. I've successfully managed to display this on every other page than the Search & Filter pages. It's either all images on the left or right, not reversing every other.
I've targeted the div id #artikel on the working pages, but that won't work. Do i need to use some kind of unique id here?
This is my css from the results php;
<section id="post-<? the_ID(); ?>" <? post_class('blok-item'); ?>>
<div class="container-wrap">
<div class="container">
<div id="search-blok" class="row">
<div id="artikel">
<div id="artikel-image" class="col-sm-12 col-md-12 col-lg-6" style="background:linear-gradient( rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.1)), url(<?php the_field( 'intro_billede' ); ?>); background-position: 0% 50%; background-size: cover;"></div>
<div id="artikel-content" class="col-sm-12 col-md-12 col-lg-6">
<div class="hotel-name-artikel">
<?php the_field( 'intro_lille_overskrift' ); ?>
</div>
<div class="artikel-overskrift">
<h2><?php the_title(); ?></h2>
</div>
<div class="artikel-intro">
<?php the_field( 'intro_tekst' ); ?>
</div>
<?php if ( get_field( 'intro_pris' ) ): ?>
<div class="pris-wrapper">
<h2 class="pris">KR. <?php the_field( 'intro_pris' ); ?>,-</h2>
<h4 class="pris-ekstra"><?php the_field( 'intro_pris_extra' ); ?></h4>
</div>
<?php endif ?>
<div class="artikel-link-container">
<?php if ( have_rows( 'links_repeater' ) ) : ?>
<?php while ( have_rows( 'links_repeater' ) ) : the_row(); ?>
<?php $side_intro_repeater_knap_url = get_sub_field( 'side_intro_repeater_knap_url' ); ?>
<?php if ( $side_intro_repeater_knap_url ) { ?>
<a class="<?php the_sub_field( 'repeater_knap_farve' ); ?>" style="float:left" href="<?php echo $side_intro_repeater_knap_url; ?>"><?php the_sub_field( 'repeater_knap_tekst' ); ?></a>
<?php } ?>
<?php endwhile; ?>
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
and the :nth-child css:
artikel:nth-last-child(odd) {
display: -webkit-flex; /* Safari */
-webkit-flex-direction: row-reverse; /* Safari 6.1+ */
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
}
Now i'm no wiz at php nor css, so the code might not be precisely as it ought to be, so please bare that in mind :)
Thanks for all help and assistance
I want the results to look just like my blocks on the rest of the
site; image on one side - text on the other, and then reverse that in
the next row.
I'm not entirely sure I understand the question, but if I do, you are definitely on the right track using flex-direction: row and flex-direction: row-reverse.
Working Example:
article {
display: flex;
flex-direction: row;
justify-content: space-between;
width: 600px;
}
article:nth-of-type(even) {
flex-direction: row-reverse;
}
.text-block,
.image-block {
flex: 1 1 50%;
}
img {
display: block;
width: 90%;
height: 150px;
margin-top: 30px;
line-height: 150px;
text-align: center;
border: 1px solid rgb(0, 0, 0);
}
<main>
<article>
<div class="text-block">
<h2>Heading</h2>
<p>Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph.</p>
</div>
<div class="image-block">
<img src="" alt="Image" />
</div>
</article>
<article>
<div class="text-block">
<h2>Heading</h2>
<p>Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph.</p>
</div>
<div class="image-block">
<img src="" alt="Image" />
</div>
</article>
<article>
<div class="text-block">
<h2>Heading</h2>
<p>Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph.</p>
</div>
<div class="image-block">
<img src="" alt="Image" />
</div>
</article>
<article>
<div class="text-block">
<h2>Heading</h2>
<p>Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph.</p>
</div>
<div class="image-block">
<img src="" alt="Image" />
</div>
</article>
</main>
This is the container and two sections which i'd like to display flex; one with the image on the left and text on the right. The next row text on the left, image on the right.
This is the container and two sections which i'd like to display flex; one with the image on the left and text on the right. The next row text on the left, image on the right.
<div class="search-filter-results" id="search-filter-results-2898">
<div class="container" style="background-color:#21002c;color:#fff;">
<div class="search-results"><h6>Viser 24 resultater</h6></div>
</div>
<div class="pagination">
<div class="nav-previous"><a href="http://staging.montra.dk/tilbud?sf_paged=2" >Ældre indlæg</a></div>
<div class="nav-next"></div>
</div>
<section id="post-3293" class="blok-item post-3293 odderparkhotel type-odderparkhotel status-publish kategori-tilbud hoteller-odder-parkhotel">
<div class="container-wrap">
<div class="container">
<div id="search-blok" class="row">
<div class="artikel">
<div class="artikel-image col-sm-12 col-md-12 col-lg-6" style="background:linear-gradient( rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.1)), url(http://staging.montra.dk/wp-content/uploads/2020/01/Weekend-intro.jpg); background-position: 0% 50%; background-size: cover;"></div>
<div class="artikel-content col-sm-12 col-md-12 col-lg-6">
<div class="hotel-name-artikel">
</div>
<div class="artikel-overskrift">
<h2>Weekendphold for 2 i Jylland</h2>
</div>
<div class="artikel-intro">
<p>Nyd et weekendophold for 2 på 4-stjernet hotel i Odder syd for Århus med velrenommeret køkken, som byder på udsøgte smagsoplevelser.</p>
</div>
<div class="pris-wrapper">
<h2 class="pris">KR. 995,-</h2>
<h4 class="pris-ekstra"></h4>
</div>
<div class="artikel-link-container">
<a class="knap-1" style="float:left" href="http://staging.montra.dk/odder-parkhotel/weekendphold-for-2-i-jylland">Læs mere</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="post-3290" class="blok-item post-3290 odderparkhotel type-odderparkhotel status-publish kategori-tilbud hoteller-odder-parkhotel">
<div class="container-wrap">
<div class="container">
<div id="search-blok" class="row">
<div class="artikel">
<div class="artikel-image col-sm-12 col-md-12 col-lg-6" style="background:linear-gradient( rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.1)), url(http://staging.montra.dk/wp-content/uploads/2020/01/Aarhus-intro.jpg); background-position: 0% 50%; background-size: cover;"></div>
<div class="artikel-content col-sm-12 col-md-12 col-lg-6">
<div class="hotel-name-artikel">
Montra Odderpark Hotel </div>
<div class="artikel-overskrift">
<h2>Mangler du også en studiebolig til studiestart 2020</h2>
</div>
<div class="artikel-intro">
<p>I Århus er der mangel på studieboliger og derfor vil vi på Montro Odder Parkhotel gerne hjælpe studerende, som er i akut boligmangel.</p>
</div>
<div class="pris-wrapper">
<h2 class="pris">KR. 2.000,-</h2>
<h4 class="pris-ekstra"></h4>
</div>
<div class="artikel-link-container">
<a class="knap-1" style="float:left" href="http://staging.montra.dk/odder-parkhotel/mangler-du-ogsaa-en-studiebolig">Læs mere</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

exclude div from parent style

I'm trying to override the .container class in bootstrap. I'm using Drupal 7 and I have a css file for my theme which is working perfectly until I want to override the .container
my HTML
<div class="main-container <?php print $container_class; ?>">
<div class="top-div" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
that PHP code will insert the class .container
I need to give the div with class .top-diva 100% size without any padding from the .container I've tried the child > selector and descendant selector and the :not(.top-div) methods nothing works. When I use the :not(.top-div) it applies changes on each and every page and element on the website AND the div which contains the .top-div which is really weird. Suggestions?
In bootstrap, the padding is applied on the container, not the inner divs. To override this on one element you need to give it negative horizontal margins.
Something like:
.container .top-div {
margin-left:-10px;
margin-right:-10px;
}
Where 10px should be replaced by the padding on .main-container.
If this doesn't work right away you may need greater specificity
Bootstrap's built-in .row class uses this method
Why don't you try:
.main-container {
position:relative;
}
.top-div {
position:absolute;
left:0;
top:0;
}
<div class="main-container <?php print $container_class; ?>">
<div class="top-div" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
If you are using bootstrap css than you don't need to give any custom css
You try to just add row class in your top-div class
it's a in built in bootstrap.css So no need for any extra custom css.
.row {
margin-left: -10px;
margin-right: -10px;
}
Example
<div class="main-container <?php print $container_class; ?>">
<div class="top-div row" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="main-container <?php print $container_class; ?>">
<div class="top-div row" style=" width:100%;background-color: #676767; font-weight:bold; color:white;">
<div class="row" style="text-align:center;">
<div class="col-md-4"> text </div>
<div class="col-md-4"> text </div>
<div class="col-md-4"> text</div>
</div>
</div>
Hope this will helps you.

How do you stack images with aligned output?

I've got these posts which are images and output I'd like to stack in a column, but the divs are stuck on top of each other. I'd like to have them stacked with a bit of margin between them. How do you stack images with aligned output?
<hr />
<div id="listingwrapper">
<div style="float:left;">
<img src="gateway/imgs/stock/profilechick.jpg" />
</div>
<div style="float:left; width: 246px;">
<span style="color:white;"><b>Wicked awesome chick goes to the</b></span><br/>
</div><br/>
<div>
<span style="color:white;"><i>600 views</i></span>
</div>
</div>
<div id="listingwrapper" style="clear:both;">
<div style="float:left;">
<img src="gateway/imgs/stock/profilechick.jpg" />
</div>
<div style="float:left; width: 246px;">
<span style="color:white;"><b>Wicked awesome chick goes to the</b></span><br/>
</div><br/>
<div>
<span style="color:white;"><i>600 views</i></span>
</div>
</div>
try this demo here
#listingwrapper {
clear: both;
margin-top: 35px;
overflow: hidden;
}

Twitter bootstrap grid not aligning

I'm having issue getting my grid to align correctly. Here is the HTML
<div class="span6" id="content">
<!-- Category 2 is Programming category. -->
<?php $programming_posts = get_posts('2'); ?>
<div class="row-fluid">
<?php foreach($programming_posts as $key => $post){ ?>
<div class="span6 well well-small" id="post-preview">
<?php echo $post->post_excerpt;?>
</div>
<?php }?>
</div>
</div>
Here is the CSS
#post-preview{
border: 1px solid rgba(140,140,140,1);
border-radius: 2px;
max-height: 135px;
min-height: 135px;
margin-bottom: 5px;
}
As you can see the first row is not aligned with the rows that comes after it. The first row is the row with the right alignment. I'm not sure how to fix this?
You html structure is bad as a row-fluid can have only maximum of 12 columns, ie in this case two <div class="span6 well well-small" id="post-preview"> elements. But in your case you are adding all post-preview divs to a single row-fluid
Your html must be structure should be like
<div class="row-fluid">
<div class="span6 well well-small" id="post-preview1">
</div>
<div class="span6 well well-small" id="post-preview2">
</div>
</div>
<div class="row-fluid">
<div class="span6 well well-small" id="post-preview1">
</div>
<div class="span6 well well-small" id="post-preview2">
</div>
</div>
Also the id should be unique in a document, you have many divs with id post-preview because of the loop
Approach A:
Since you have 4 blocks, you can use span3 class:
<div class="span3 well well-small" id="post-preview">
<?php echo $post->post_excerpt;?>
</div>
Approach B:
If you want to keep the width and only display a pair of blocks in one line, then you can split pairs of divs into separate row-fluid (PHP code is just for reference):
<div class="row-fluid">
<div class="span6 well well-small" id="post-preview1">
<?php echo $post->post_excerpt;?>
</div>
<div class="span6 well well-small" id="post-preview2">
<?php echo $post->post_excerpt;?>
</div>
</div>
<div class="row-fluid">
<div class="span6 well well-small" id="post-preview1">
<?php echo $post->post_excerpt;?>
</div>
<div class="span6 well well-small" id="post-preview2">
<?php echo $post->post_excerpt;?>
</div>
</div>