Why doesn't the title and date line up? - css

Here is a snippet from some generated html I am trying to style. Why does the date align to the top but the link inside the h3 doesn't?
Using dev tools I can see the link is centrally aligned to the h3 vertically but I cant alter it in any way I have tried with vertical-align or by adjusting height.
article {
width: 400px;
}
article .date_posted {
float: right;
font-size: 12px;
}
article div.thumbnail {
margin-right: 10px;
width: 100px;
height: 75px;
float: left;
box-shadow: 0 0 0 4px #fff, 0 0 0 5px red;
vertical-align: text-top;
}
article div.title h3 {
display: inline;
}
article div.title h3 a {
font-size: 14px;
font-family: Lato, sans-serif;
font-weight: 900;
color: red;
}
article:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
<article>
<div class="uposts-part thumbnail" data-resize="1">
<img width="288" height="230" src="http://site3.wpmu-subdomain.dev/wp-content/uploads/sites/3/2015/10/0f02bd48-7efe-3934-8f4b-093c81560333.jpg" class="attachment-post-thumbnail wp-post-image" alt="" style="margin-top: -2.5px; height: auto; width: 100%;">
</div>
<div class="uposts-part date_posted">
<span class="date">23</span>, <span class="time">October</span></div>
<div class="uposts-part title">
<h3>Dignissimos deserunt fugiat at sdfsfsd sdfsd s fsdf s ds fds df sdf sdf sd f sd fsd d</h3>
</div>
</article>
JS fiddle: https://jsfiddle.net/xdfc8vnm/

article div.title {
float: left;
width: 233px;
line-height: 1
}
article div .title h3 {
display: inline;
margin: 0;
}
article div.title h3 a {
font-size: 14px;
font-family: Lato, sans-serif;
font-weight: 900;
color: red;
display: block;
}
article .date_posted {
float: right;
font-size: 12px;
line-height: 1;
}

For your class: article .date_posted you need to set same Font Family, Font Size and Font Weight that you used on post title. So it should go like this:
article .date_posted {
float: right;
font-size: 14px; /* from 12px changed to 14px */
text-decoration: underline; /* this line added */
font-family: Lato, sans-serif; /* this line added */
font-weight: 900; /* this line added */
}
Here is an example: https://jsfiddle.net/LddvoLaL/2/

Related

How to make the flex item text wrapped under the adjutants item

How to get the text wrapped under the points?
https://codepen.io/neginbasiri/pen/ZEGReRZ
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3
pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt">
Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13">
<span>3</span></sup> </span></p></div>
In the example switch should show under 16,000.
.bUhvVh {
display: flex;
margin-bottom: 20px;
width: 300px;
}
.iBQvHK {
color: #e40000;
font-size: 24px;
margin-right: 10px;
border: 1px solid red;
width: 20px;
}
.icon--icon--base--17 {
height: 1em;
min-width: 1em;
vertical-align: middle;
fill: currentColor;
}
.cPwDGx {
font-family: Ciutadella Regular;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
.enMiay {
float: left;
font-family: Ciutadella Medium;
margin-right: 4px;
position: relative;
color: #323232;
}
.dufgDt {
margin: 0;
font-family: 'Ciutadella Regular',sans-serif;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3 pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt"> Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13"><span>3</span></sup> </span></p></div>
</div>
Remove display: flex; flex: 1 from .cPwDGx.
Remove display: inline-block from .enMiay and add float: left for this element.
Update width to min-width for icon--icon--base--17. It will not shrink if text is larger.
Refer : https://codepen.io/bala_tamizh/pen/WNvyEPg

Centering a content in all devices using padding-top

I have been having trouble centering the .content div in any device. In some devices, the .content is exactly centered but not in others. I use padding-top to push the .content down so it could be placed on the center of any device. What should I do to center the .content in any device using padding-top? Should I use Javascript in this kind of situation?
body {
margin: 0;
}
.whole {
height: 100vh;
background: #d44949;
}
header:after {
content: '';
display: table;
clear: both;
}
.logo {
font: 1.4em 'Open Sans',sans-serif;
color: #fcfcfc;
text-transform: uppercase;
float: left;
margin-left: 15px;
}
.logo > span {
font-style: italic;
color: #d8d8d8;
}
.header-nav {
float: right;
margin: 20px 15px 0 0;
}
.header-nav > a {
color: #fafafa;
text-decoration: none;
font: 1em 'Open Sans',sans-serif;
font-weight: 300;
}
.header-nav > a:not(:first-child) {
margin-left: 15px;
}
.header-nav > a:hover {
color: yellow;
}
.content {
display: flex;
flex-direction: column;
padding-top: calc(100vh / 2);
}
.content > img {
width: 200px;
height: 200px;
border-radius: 50%;
margin: auto;
}
.content-nav {
margin: auto;
padding-top: 20px;
}
.content-nav > a {
color: #fafafa;
text-decoration: none;
font: 1em 'Open Sans',sans-serif;
font-weight: 300;
}
.content-nav > a:not(:first-child) {
margin-left: 10px;
}
<div class="whole">
<header>
<h1 class="logo">Max<span>&</span>Spoon</h1>
<div class="header-nav">
Download
Docs
Tutorial
Reference
</div>
</header>
<div class="content">
<img src="http://emblemsbf.com/img/36593.jpg" alt="logo">
<div class="content-nav">
Home
Blog
Forum
Stuff
</div>
</div>
</div>
As you are already using flex you could remove the padding-top and add align-items: center; to your .content.
So your CSS for .content becomes:
.content {
display: flex;
flex-direction: column;
align-items: center;
}
Here's the updated snippet.
body {
margin: 0;
}
.whole {
height: 100vh;
background: #d44949;
}
header:after {
content: '';
display: table;
clear: both;
}
.logo {
font: 1.4em'Open Sans', sans-serif;
color: #fcfcfc;
text-transform: uppercase;
float: left;
margin-left: 15px;
}
.logo > span {
font-style: italic;
color: #d8d8d8;
}
.header-nav {
float: right;
margin: 20px 15px 0 0;
}
.header-nav > a {
color: #fafafa;
text-decoration: none;
font: 1em'Open Sans', sans-serif;
font-weight: 300;
}
.header-nav > a:not(:first-child) {
margin-left: 15px;
}
.header-nav > a:hover {
color: yellow;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
}
.content > img {
width: 200px;
height: 200px;
border-radius: 50%;
margin: auto;
}
.content-nav {
margin: auto;
padding-top: 20px;
}
.content-nav > a {
color: #fafafa;
text-decoration: none;
font: 1em'Open Sans', sans-serif;
font-weight: 300;
}
.content-nav > a:not(:first-child) {
margin-left: 10px;
}
<div class="whole">
<header>
<h1 class="logo">Max<span>&</span>Spoon</h1>
<div class="header-nav">
Download
Docs
Tutorial
Reference
</div>
</header>
<div class="content">
<img src="http://emblemsbf.com/img/36593.jpg" alt="logo">
<div class="content-nav">
Home
Blog
Forum
Stuff
</div>
</div>
</div>

Margins work fine on chrome but not on firefox

I'm learning basic CSS currently, I'm trying to create a little mockup product page that uses a grid system with 4 columns. It looks and works fine on chrome, but on Firefox it breaks like such. Here's how it looks like on Firefox:
I can't seem to figure out how to fix it, I've tried changing the margins/padding from various locations but to no avail, it's still messing up on Firefox.
Here's my CSS:
html {
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
background: #232526; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #232526 , #414345); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #232526 , #414345); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
* {
box-sizing: border-box;
}
.menu {
background-color: #17534b;
position: absolute;
width: 99.23%;
height: 8vh;
}
ul.nav {
width: 100%;
}
ul.nav li {
list-style: none outside none;
display: inline-block;
width: 19%;
text-align: center;
}
ul.nav li a {
display: block;
text-align: center;
padding: 1.5em;
color: #ffffff;
letter-spacing: 1px;
font-size: 15px;
text-transform: uppercase;
text-decoration: none;
}
ul.nav li a:hover {
background-color: #000000;
color: white;
}
ul.nav li.li-ultimate{
text-transform: uppercase;
color: #eef2ff;
font-size: 25px;
}
section {
width: 100%;
padding: 0 7%;
display: table;
margin: 0;
max-width: none;
height: 100vh;
}
.welcome {
height: 100vh;
background-color: #ffffff;
}
.content {
display: table-cell;
vertical-align: middle;
}
.welcome h1{
font-size: 3em;
display: block;
color: black;
font-weight: 300;
}
.welcome h2 {
font-size: 1.5em;
display: block;
color: black;
font-weight: 200;
}
.productsheader {
color: #ffffff;
}
.productsheader h1{
text-align: center;
color: #ffffff;
font-size: 3em;
}
.products{
height:100vh;
}
ul.rig {
padding: 5%;
list-style: none;
font-size: 0px;
margin-left: -2.5%;
}
ul.rig li {
display: inline-block;
padding: 10px;
margin: 0 0 2.5% 2.5%;
background: #ffffff;
border: 1px solid #ddd;
font-size: 16px;
vertical-align: top;
box-shadow: 0 0 5px #ddd;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
ul.rig li img {
max-width: 100%;
height: auto;
margin: 0 0 10px;
}
ul.rig li h3 {
margin: 0 0 5px;
text-align: center;
}
ul.rig li p {
font-size: .9em;
line-height: 1.5em;
color: #999;
text-align: center;
}
ul.rig.columns-4 li {
width: 22.5%;
}
Along with the relevant HTML:
<section class="products">
<div class="content">
<div class="productsheader">
<h1>
Our Proudly Presented Products
</h1>
</div>
<ul class="rig columns-4">
<li>
<img src="images/1.jpg"/>
<h3>Is-it-even-a-cup Cup - $100</h3>
<p>Life's true questions.</p>
</li>
<li>
<img src="images/2.jpg"/>
<h3>Flute Looking Cup - $150</h3>
<p>Looks like a flute.</p>
</li>
<li>
<img src="images/3.jpg"/>
<h3>Uterus Looking Cup - $350</h3>
<p>Modelled after a woman's uterus. Probably.</p>
</li>
<li>
<img src="images/4.jpg"/>
<h3>Artistic Cup - $1</h3>
<p>Artsy...ish...</p>
</li>
<li>
<img src="images/5.jpeg"/>
<h3>Ancient Cup - $500</h3>
<p>Or at least we think its old. Sure does look it.</p>
</li>
<li>
<img src="images/6.jpg"/>
<h3>Chinese Poetic Cup - $250</h3>
<p>The cup feels empty when you drink, but you're empty when you don't.</p>
</li>
<li>
<img src="images/7.jpg"/>
<h3>Dragonfly Cup - $25</h3>
<p>Pretty little dragonfly...On a cup.</p>
</li>
<li>
<img src="images/8.png"/>
<h3>FIFA World Cup Brazil - $50</h3>
<p>Technically a cup...</p>
</li>
</ul>
</div>
</section>
Are there any tips to also prevent this from happening in the future when I work on another css project?
ul.rig {
padding: 5%;
list-style: none;
font-size: 0px;
margin-left: -2.5%;
width: 960px; // choose your width like 960px
margin: auto; // auto work with display : block for centering
display: block; // block work with margin : auto for centering
}

Trouble with div in div positioning

You can visit the site I am working on here.
You can see what I am going for. I want the bottom right box to mimic the top right box in its positioning, but for some reason it refuses to fill the rest its parent div and opts to stack vertically. Even without content the background stops about half way through the box. I have it set to float left (something that shouldn't be necessary as div children should take their parent's width automatically), so I'm guessing there is something actually there but I cannot tell what. I have tried to clear and such but no luck there either. Is there a way to get that bottom right div to actually fill the parent div?
Here is my HTML
<div id="menu-ad">
<div>
<p class="titles">Our Fare</p>
<p id="ad">Our lunch and dinner menus feature European inspired comfort food accompanied by an extensive bar.</p>
VIEW MENU
</div>
</div><!--end menu ad-->
<div id="hours">
<div>
<p class="titles">Hours</p>
<p class="subtitles">Lunch</p>
<p class="subtitles">Dinner</p>
<p class="subtitles">Bar</p>
</div>
<div>
<p class="hours">Mon-Fri 11-4</p>
<p class="hours">Mon-Sat 4-12</p>
<p class="hours">Mon-Sat 4-12</p>
</div>
</div><!--end hours-->
And my CSS
/*menu ad*/
div#menu-ad {
position: relative;
margin-right: -11px;
margin-top: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
border-bottom: 2px solid #b9aea3;
overflow: hidden;
}
div#menu-ad div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
height: 200px;
display: inline-block;
}
.titles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2.5rem;
color: #d6832e;
}
#ad {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.6rem;
line-height: 1.35;
color: #4f4d4b;
margin-top: .5rem;
width: auto;
}
a#button {
padding: .6rem 1.3rem .6rem 1.3rem;
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.8rem;
color: #fff;
background: #d6832e;
text-align: center;
vertical-align: middle;
text-decoration: none;
position: absolute;
float: left;
bottom: 3.5rem;
}
/*hours*/
div#hours {
position: relative;
margin-top: -1px;
margin-right: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
}
div#hours div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
width: auto;
height: 150px;
display: inline-block;
}
.subtitles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2rem;
color: #4f4d4b;
text-align: left;
line-height: 2;
}
.hours {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.7rem;
color: #4f4d4b;
text-align: right;
line-height: 2;
}
Thanks for any help or advice!
If you change your structure a little, it might help you. Instead of trying to float to divs side by side, you could just join them together kinda like I did with the HTML and css below. I added comments where I changed stuff in the css.
HTML
<div id="menu-ad">
<div>
<p class="titles">Our Fare</p>
<p id="ad">Our lunch and dinner menus feature European inspired comfort food accompanied by an extensive bar.</p>
VIEW MENU
</div>
</div><!--end menu ad-->
<div id="hours">
<div>
<p class="titles">Hours</p>
<p>
<span class="subtitles">Lunch</span>
<span class="hours">Mon-Fri 11-4</span>
</p>
<p>
<span class="subtitles">Dinner</span>
<span class="hours">Mon-Sat 4-12</span>
</p>
<p>
<span class="subtitles">Bar</span>
<span class="hours">Mon-Sat 4-12</span>
</p>
</div>
</div><!--end hours-->
CSS:
/*menu ad*/
div#menu-ad {
position: relative;
margin-right: -11px;
margin-top: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
border-bottom: 2px solid #b9aea3;
overflow: hidden;
}
div#menu-ad div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
height: 200px;
display: inline-block;
}
.titles {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2.5rem;
color: #d6832e;
}
#ad {
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.6rem;
line-height: 1.35;
color: #4f4d4b;
margin-top: .5rem;
width: auto;
}
a#button {
padding: .6rem 1.3rem .6rem 1.3rem;
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.8rem;
color: #fff;
background: #d6832e;
text-align: center;
vertical-align: middle;
text-decoration: none;
position: absolute;
float: left;
bottom: 3.5rem;
}
/*hours*/
div#hours {
position: relative;
margin-top: -1px;
margin-right: -11px;
width: 268px;
height: auto;
float: right;
padding: 11px 11px 10px 10px;
border-left: 2px solid #b9aea3;
}
div#hours div {
background: #f9f4df;
padding: 1.9rem 4rem 2.5rem 2.5rem;
width: auto;
height: 150px;
/***** Removed Display:inline-block *****/
}
.subtitles {
float:left; /**** Added ****/
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 2rem;
color: #4f4d4b;
text-align: left;
line-height: 2;
}
.hours {
float:right; /**** Added ****/
font-family: "Montserrat", "Helvetica", sans-serif;
font-size: 1.7rem;
color: #4f4d4b;
text-align: right;
line-height: 2;
}
#hours p {clear:both;} /**** Added ****/
All you need to do is to decrease the inner-div size that fits to your #hours div and assign a class to each of the inner div and float them left and right.
Example
<div id="hours">
<div class="left">
<p class="titles">Hours</p>
<p class="subtitles">Lunch</p>
<p class="subtitles">Dinner</p>
<p class="subtitles">Bar</p>
</div>
<div class="right">
<p class="hours">Mon-Fri 11-4</p>
<p class="hours">Mon-Sat 4-12</p>
<p class="hours">Mon-Sat 4-12</p>
</div>
</div><!--end hours-->
CSS:
#hours .left
{
float: left;
}
#hours .right
{
float: right;
}
It will help for sure. Also start using browser`s consoles. They ease your life.
I take it your trying to make the Hours take up the entire box?
If so, add this code to it:
height: 100%;
width: 100%;
padding: 0px;
Use followig. Those which are commented in here, need to remove form your code.
div.container {
/*height: 460px;*/
/*padding: 10px*/
padding: 10px 10px 0px; /* bottom padding 0px */
}
div#hours div {
/*inline-block*/
}
Now add following after ending tag of #hours.
<div style="clear:both;"></div>
To make #hours div look nice, use following.
<div id="hours">
<h3 class="titles">Hours</h3>
<dl>
<dt>Lunch</dt>
<dd>Mon-Fri 11-4</dd>
<dt>Dinner</dt>
<dd>Mon-Sat 4-12</dd>
<dt>Bar</dt>
<dd>Mon-Sat 4-12</dd>
</dl>
</div><!--end hours-->
CSS Styles -
#hours dl,
#hours dt,
#hours dd {
margin: 0;
padding: 0;
}
#hours dl {
width: 100%;
float: left;
clear: both;
}
#hours dl dt {
float: left;
clear: left;
width: 45%;
}
#hours dl dd {
float: left;
}

CSS reset does not allow a different vertical align

I used a css reset where * selector has
vertical-align:baseline;
Entire theme was build with it, and now, at the very end, I need one div to align top. And it does not. I did specify it in styling, added !important. No luck. I'm sure I'm missing something, but can't figure out what.
So
Css reset * selector part looks like this
* {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
Html part
php part of wordpress templates
<li>
<div id="datencomments">
<div id="date3">
<div id="datetxt">
<div class="month"><?php the_time('M ') ?></div>
<div class="day"><?php the_time('j ') ?></div>
</div></div>
<div id="comments"><span class="comments-link"><?php comments_popup_link( __( '1 Comment', 'blankslate' ), __( '% Comments', 'blankslate' ) ); ?></span></div>
</div>
</li>
</ul>
</div>
css for it.
.postpreview ul {
list-style: none;
}
.postpreview ul li {
display: inline-block;
}
#datencomments {
width: 100px;
vertical-align: top !important;
}
#date3 {
width:100px;
height: 100px;
border: 2px solid transparent;
border-radius: 100px;
background-color: #17B1BE;
color: #fff;
text-align: center;
}
.month {
text-align: center;
margin-top: 12px;
text-transform: uppercase;
font-size: 24px;
font-weight: 200;
font-family: 'Exo 2', sans-serif;
}
.day {
text-align: center;
margin-top: -8px;
text-transform: uppercase;
font-size: 40px;
font-family: 'Exo 2', sans-serif;
}
#comments {
margin-top: 20px;
text-align: center;
font-size: 12px;
font-family: 'Droid Serif', serif;
font-style: italic;
text-decoration: underline;
}
the rest is transitions, hover colors etc...
I need #datencomments at the top of the template, while * is pulling it down.
If done like this, display:block puts the text behind the box, display:inline puts it inside on top and display:inline-block puts the text where it is specified with vertical-align.
<div id='container'>
<div id='text'>This is a test</div>
</div>
#container{
height: 200px;border: 5px solid blue;text-align:center;
}
#text,#container:before{
vertical-align: middle;
display: inline-block;
}
#container:before{
content: "";
height: 100%;
}

Resources