I have four divs which shows a number, I want to display the words below those numbers. I have tried using the p tag with white-space: pre; in css, but still it does not work:
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
}
p {
white-space: pre;
}
<div id="c">
<span class='cnum'>27 Text1</span><span class='cnum'>10 Text2</span><span class='cnum'>40 Text 3</span><span class='cnum'>5 Text 4</span>
</div>
HTML
<div id="c">
<div class='cnum'>27 <br/>Text1</div>
<div class='cnum'>10 <br/>Text2</div>
<div class='cnum'>40 <br/>Text 3</div>
<div class='cnum'>5 <br/>Text 4</div>
</div>
CSS
#c{
padding-top:30px;
padding-bottom:30px;
}
.cnum{
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin:5px;
font-size:20px;
max-Width :100px;
float :left
}
Heres a CodePen
If you can't edit the HTML, here's a workaround using word-spacing. Obviously this method is very limited...
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
display: inline-block;
width: 100px;
word-spacing: 100px;
}
<div id="c">
<span class='cnum'>27 Text1</span><span class='cnum'>10 Text2</span><span class='cnum'>40 Text3</span><span class='cnum'>5 Text4</span>
</div>
I just separated the elements according to the hierarchy so that I could then apply the style. If you observe keep the span tags, but you could replace them with a block element.
I recommend you to learn about inline and block HTML elements and how to convert them in each other.
I hope I have contributed.
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
display: inline-block;
text-align: center;
}
.cnum span{
display: block;
}
p {
white-space: pre;
}
<div id="c">
<div class="cnum">
<span>27</span>
<span>Text 1</span>
</div>
<div class="cnum">
<span>10</span>
<span>Text 2</span>
</div>
<div class="cnum">
<span>40</span>
<span>Text 3</span>
</div>
<div class="cnum">
<span>5</span>
<span>Text 4</span>
</div>
</div>
If you can edit the html you can do the following, additionally using the pseudo selector ::first-line style the numbers differently
#c {
padding-top: 30px;
padding-bottom: 30px;
}
.cnum {
background: black;
border-radius: 5px;
color: #fff;
padding: 15px;
margin: 5px;
font-size: 20px;
}
.cnum::first-line {
font-size: 30px;
color: yellow;
}
<div id="c">
<div class='cnum'>27 <br/>Text1</div>
<div class='cnum'>10 <br/>Text2</div>
<div class='cnum'>40 <br/>Text 3</div>
<div class='cnum'>5 <br/>Text 4</div>
</div>
Related
Is there a way to centralize text inside a bordered element?
When I do border at the element, maybe because its content size is reduced, it gets decentralized.
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You can use flexbox to center the text element:
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
/*Add*/
display: flex;
justify-content: center;
align-items: center;
}
<div style="max-width: 15px;">
<h3>With border</h3>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
You could try this:
.circle {
text-align: center;
line-height: 20px;
}
I was able to center it using display: flex.
Check it's browser support though: https://caniuse.com/#feat=flexbox
.circle {
width: 22px;
height: 22px;
border-radius: 50%;
border: solid #00b0ff 1px;
color: #00b0ff;
display: flex;
justify-content: center;
align-items: center;
}
.button-styling {
color: #00b0ff;
font-size: x-large;
}
.outline-h {
outline: thin;
outline-color: blue;
outline-style: solid;
}
<div style="max-width: 15px;">
<h3> With border </h1>
<div class="circle">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
<div style="max-width: 15px;">
<h3> Without border </h1>
<div class="outline-h">
<mat-icon class="button-styling">+</mat-icon>
</div>
</div>
What is the correct way of resizing divs with text in it? I use the code below, but it leaves me with noticeable font distortion when resizing. Its kinda like the font has changed during animation. Also there is a flicker inside the circles. The effect isn't really visible on OSX, but it is on windows machines. How do I fix it?
.content-no-btn {
transition: all .2s ease-in-out;
}
.content-no-btn:hover {
transform: scale(1.05);
}
.entry-content {
border-style: solid;
border-color: #bbb;
border-width: 0px 3px 3px 3px;
padding-top: 20px;
}
#price {
text-align: center;
}
.plan {
display: inline-block;
margin: 10px 1%;
font-family: 'Lato', Arial, sans-serif;
}
.plan-inner {
background: #fff;
margin: 0 auto;
min-width: 280px;
max-width: 100%;
position: relative;
}
.entry-title {
background: #53CFE9;
height: 140px;
position: relative;
text-align: center;
color: #fff;
margin-bottom: 0px;
}
.entry-title>h3 {
background: #20BADA;
font-size: 20px;
padding: 5px 0;
text-transform: uppercase;
font-weight: 700;
margin: 0;
}
.entry-title .price {
position: absolute;
bottom: -25px;
background: #20BADA;
height: 95px;
width: 95px;
margin: 0 auto;
left: 0;
right: 0;
overflow: hidden;
border-radius: 50px;
border: 4px solid #fff;
line-height: 80px;
font-size: 23px;
font-weight: 700;
}
.price span {
position: absolute;
font-size: 8px;
bottom: -10px;
left: 30px;
font-weight: 400;
}
.entry-content {
color: #323232;
padding-top: 20px;
}
.entry-content ul {
margin: 0;
padding: 0;
list-style: none;
text-align: center;
}
.entry-content li {
border-bottom: 1px solid #E5E5E5;
padding: 10px 0;
}
.entry-content li:last-child {
border: none;
}
.btn {
padding: 5em 0 5em 0;
text-align: center;
}
.btn a {
background: #323232;
padding: 10px 30px;
color: #fff;
text-transform: uppercase;
font-weight: 700;
text-decoration: none
}
.hot {
position: absolute;
top: -7px;
background: #F80;
color: #fff;
text-transform: uppercase;
z-index: 2;
padding: 2px 5px;
font-size: 9px;
border-radius: 2px;
right: 10px;
font-weight: 700;
}
.basic .entry-title {
background: #f37920;
}
.basic .entry-title > h3 {
background: #E7680C;
}
.basic .price {
background: #f37920;
}
.standard .entry-title {
background: #4484c1;
}
.standard .entry-title > h3 {
background: #3772aa;
}
.standard .price {
background: #3772aa;
}
.ultimite .entry-title > h3 {
background: #DD4B5E;
}
.ultimite .entry-title {
background: #F75C70;
}
.ultimite .price {
background: #DD4B5E;
}
.gratitude {
padding: 5em 20px 5em 20px;
height: 300px;
text-align: center;
background-color: #f8f9f9;
}
.orderDetailsContent {
max-width: 800px;
text-align: center;
display: table;
position: relative;
margin: auto;
}
<div id="price">
<!--price tab-->
<div class="plan">
<div class="plan-inner">
<div class="content-no-btn">
<div class="entry-title first-entry-title">
<h3>WHATUP </h3>
<div class="price">$0.99<span></span>
</div>
</div>
<div class="entry-content first-entry-content">
<ul>
<li><strong>SOME text here</strong></li>
<li><strong>and here too</strong> really</li>
<li><strong>and here too</strong> Effective</li>
<li><strong>HEHE</strong> and here too</li>
</ul>
</div>
</div>
<div class="btn">
Order Now
</div>
</div>
</div>
<!-- end of price tab-->
<!--price tab-->
<div class="plan basic">
<div class="plan-inner">
<div class="content-no-btn">
<div class="entry-title">
<h3>YEAH </h3>
<div class="price">$1.99<span></span>
</div>
</div>
<div class="entry-content">
<ul>
<li><strong>SOME text here</strong></li>
<li><strong>and here too</strong> really</li>
<li><strong>and here too</strong> Effective</li>
<li><strong>HEHE</strong> and here too</li>
</ul>
</div>
</div>
<div class="btn">
Order Now
</div>
</div>
</div>
<!-- end of price tab-->
<!--price tab-->
<div class="plan standard">
<div class="plan-inner">
<div class="content-no-btn">
<div class="hot">hot</div>
<div class="entry-title">
<h3>Superduper</h3>
<div class="price">$2.99<span></span>
</div>
</div>
<div class="entry-content">
<ul>
<li><strong>SOME text here</strong></li>
<li><strong>and here too</strong> really</li>
<li><strong>and here too</strong> Effective</li>
<li><strong>HEHE</strong> and here too</li>
</ul>
</div>
</div>
<div class="btn">
Order Now
</div>
</div>
</div>
<!-- end of price tab-->
<!--price tab-->
<div class="plan ultimite">
<div class="plan-inner">
<div class="content-no-btn">
<div class="entry-title">
<h3>JustGreat</h3>
<div class="price">$3.99<span></span>
</div>
</div>
<div class="entry-content">
<ul>
<li><strong>SOME text here</strong></li>
<li><strong>and here too</strong> really</li>
<li><strong>and here too</strong> Effective</li>
<li><strong>HEHE</strong> and here too</li>
</ul>
</div>
</div>
<div class="btn">
Order Now
</div>
</div>
</div>
<!-- end of price tab-->
</div>
<div class="gratitude"></div>
Scale transformations of such a small percentage are notorious for this. The only way around it is better browsers.
Instead, consider a translate animation with a whole number of pixels, perhaps upwards. You can also get some scale effect by setting position:relative on .content-no-btn then adding an absolutely positioned ::before with 100% width and height, and scaling only that pseudo-element on hover.
How would I go about doing that;
this is my current wip:
https://jsfiddle.net/Lg0wyt9u/967/
<li>
<div class='type'><i class='fa fa-arrow-circle-right'>I</i></div>
<div class='details'>
<div class='date'>date</div>
<div class='address'>1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
</div>
<div class='value'>1.2</div>
<div class='slide-in'>
DELETE
</div>
</li>
The delete button is hidden for the moment.
What should happen is, it gets revealed, and the other content is pushed "off-canvas" to the same width as this element. However, I'm unsure of how to proceed. I use display:flex and tried some positioning but it didn't work.
Here you go:-
$(document).ready(function(){
$('.list ul li .rw').click(function(){
console.log(this);
$(this).css("right","65px");
$('.slide-in').css("display","block");
})
})
ul {
list-style-type: none;
margin: 0;
padding: 0;
border: 1px solid black;
}
.rw{
padding-top: 20px;
width:100%;
cursor:pointer;
position:absolute;
padding-bottom: 20px;
border-bottom: 1px solid #a1d1b8;
display: flex;
justify-content: space-between;
align-items: center;
}
.type {
padding-right: 15px;
flex: 0 0 50px;
background: green;
}
.type i {
font-size: 40px;
}
.details {
flex: 1;
overflow: hidden;
font-family: "Courier New";
}
.address {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.value {
padding-left: 15px;
font-size: 55px;
}
.date {
font-weight: bold;
margin-bottom: 5px;
}
.slide-in {
width:65px;
background: red;
color: #fff;
display:none;
}
<div id="container">
<div class="list">
<ul>
<li>
<div class="rw">
<div class='type'><i class='fa fa-arrow-circle-right'>I</i></div>
<div class='details'>
<div class='date'>date</div>
<div class='address'>1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</div>
</div>
<div class='value'>1.2</div>
<div class='slide-in'>
DELETE
</div>
</div>
</li>
</ul>
</div>
</div>
You have include jQuery for this solution...
So, I'm trying to make this boxes that will hold some text and maybe some img brackground, but boxes won't align like they should on a small screen.
I tried a few things, but text won't align on the botton without destroying the alignment
CSS:
.bigbox {
text-align: center;
padding: 80px 40px;
}
.bigbox .bigbox-title {
text-align: left;
font-size: 28px;
color: #fff;
}
.bigbox .bigbox-text {
text-align: left;
font-size: 18px;
color: #fff;
opacity: .85;
margin-bottom: 20px;
}
.smallbox {
text-align: center;
padding: 80px 40px;
}
.smallbox.smallbox-title {
text-align: left;
font-size: 28px;
color: #fff;
}
.smallbox.smallbox-text {
text-align: left;
font-size: 18px;
color: #fff;
opacity: .85;
margin-bottom: 20px;
}
HTML
<div class="full-width-container">
<div class="row no-space-row ">
<div class="col-sm-6 bg-color-base">
<div class="bigbox ">
<h2 class="bigbox-title">BOX 1</h2>
<p class="bigbox-text">DESCRIPTION</p>
</div>
</div>
<div class="col-sm-6">
<div class="smallbox bg-color-purple ">
<h2 class="smallbox-title">BOX 1</h2>
<p class="smallbox-text">DESCRIPTION</p>
</div>
<div class="smallbox bg-color-purple-dark ">
<h2 class="smallbox-title">BOX 1</h2>
<p class="smallbox-text">DESCRIPTION</p>
</div>
</div>
</div>
</div>
The key in this is display:flex on the parent div. This is forcing the two child divs to be the same height.
I have removed the padding from the second div to move it closer to the big box, then position:absoluted the big box title to the bottom of the div.
I've also played with the padding a bit to help with styling - but haven't got it styled to look just like the image above.
.row {
display:flex;
}
.bg-color-base {
background:red;
}
.bg-color-base + div{
padding:0;
}
.bg-color-purple {
background:purple;
}
.bg-color-purple-dark {
background:blue;
}
.bigbox {
text-align: center;
padding: 40px;
position:absolute;
bottom:0;
}
.bigbox .bigbox-title {
align-self: flex-end;
text-align: left;
font-size: 28px;
color: #fff;
}
.bigbox .bigbox-text {
text-align: left;
font-size: 18px;
color: #fff;
opacity: .85;
margin-bottom: 20px;
}
.smallbox {
text-align: center;
padding: 160px 40px 10px;
}
.smallbox.smallbox-title {
text-align: left;
font-size: 28px;
color: #fff;
}
.smallbox.smallbox-text {
text-align: left;
font-size: 18px;
color: #fff;
opacity: .85;
margin-bottom: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="full-width-container">
<div class="row no-space-row ">
<div class="col-xs-6 bg-color-base">
<div class="bigbox ">
<h2 class="bigbox-title">BOX 1</h2>
<p class="bigbox-text">DESCRIPTION</p>
</div>
</div>
<div class="col-xs-6">
<div class="smallbox bg-color-purple ">
<h2 class="smallbox-title">BOX 2</h2>
<p class="smallbox-text">DESCRIPTION</p>
</div>
<div class="smallbox bg-color-purple-dark ">
<h2 class="smallbox-title">BOX 3</h2>
<p class="smallbox-text">DESCRIPTION</p>
</div>
</div>
</div>
</div>
Here you go. The text has to be in an absolutely positioned div.
http://codepen.io/ruchiccio/pen/Kzbeqa
.bcenter {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin-right: auto;
margin-left: auto;
width: 100%;
text-align:center;
}
Have the following problem. I need to make a table with columns that will stretch across the full length of a div block container, so it would look something like this:
However, what I have at the moment is something like this:
The code I use is:
<div class="widgetright">
<div class="widgettext">
<b>This free independent travel guide to Russia</b> exists thanks to the commission we get when you order these <b>hand-picked trusted third-party services</b> or when you <b>buy our book</b>. Please, support us!
</div>
<br>
<div class="widgetable">
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>russian visa</div><div class="gapper"> </div>
<div class="widgetbars"><span class="centerer"></span>train tickets</div>
</div>
<div class="vertgapper"></div>
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>guide book</div><div class="gapper"></div>
<div class="widgetbars"><span class="centerer"></span>hotels</div>
</div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
</div>
and the css is:
.widgetright {
border-bottom: 1px solid #b7b7b7;
}
.widgettext {
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
}
.widgettext a{
text-decoration: none;
color: #333;
}
.widgettable {
position: relative;
width: 100%;
display: table;
border-collapse: separate;
border-spacing: 20px;
}
.widgetrow {
position: relative;
width: 100%;
display:table-row;
}
.widgetbars {
width: 40%;
height: 32px;
background-color: #dfdfdf;
display:table-cell;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
text-align: center;
color: #333;
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
}
.widgetbars a {
color: #333;
}
.widgetbars a:hover {
color: #02aace;
text-decoration: underline;
}
.centerer {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.gapper {
display: table-cell;
width: 20px;
}
.vertgapper {
display:table-row;
height: 10px;
}
Thank you!
You'll need to add display:table to the .widgetable.
Since you're using table-row, using table on the parent element helps in mimicking a table structure.
After adding that, just do a quick spelling fix -- you have widgettable (with two T's) in the css, and a class named widgetable (with one T) on your actual element.
.widgetright {
border-bottom: 1px solid #b7b7b7;
}
.widgettext {
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
}
.widgettext a{
text-decoration: none;
color: #333;
}
.widgetable {
position: relative;
width: 100%;
display: table;
border-collapse: separate;
border-spacing: 20px;
display:table;
}
.widgetrow {
position: relative;
width: 100%;
display:table-row;
}
.widgetbars {
width: 40%;
height: 32px;
background-color: #dfdfdf;
display:table-cell;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
-ms-border-radius: 5px;
-khtml-border-radius: 5px;
border-radius: 5px;
text-align: center;
color: #333;
font-size: 16px;
font-family: Arial, Helvetica, sans-serif;
}
.widgetbars a {
color: #333;
}
.widgetbars a:hover {
color: #02aace;
text-decoration: underline;
}
.centerer {
display: inline-block;
height: 100%;
vertical-align: middle;
}
.gapper {
display: table-cell;
width: 20px;
}
.vertgapper {
display:table-row;
height: 10px;
}
<div class="widgetright">
<div class="widgettext">
<b>This free independent travel guide to Russia</b> exists thanks to the commission we get when you order these <b>hand-picked trusted third-party services</b> or when you <b>buy our book</b>. Please, support us!
</div>
<br>
<div class="widgetable">
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>russian visa</div><div class="gapper"> </div>
<div class="widgetbars"><span class="centerer"></span>train tickets</div>
</div>
<div class="vertgapper"></div>
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>guide book</div><div class="gapper"></div>
<div class="widgetbars"><span class="centerer"></span>hotels</div>
</div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
</div>
I tried this:
.widgetbars {
width: 50%;
margin-right:30px;
...
}
You can see a demo here: http://jsfiddle.net/4ry7agzp/
HTML
<div class="widgetright">
<div class="widgettext">
<b>This free independent travel guide to Russia</b> exists thanks to the commission we get when you order these <b>hand-picked trusted third-party services</b> or when you <b>buy our book</b>. Please, support us!
</div>
<br>
<div id="container"> /*New div added. Every thing is wraped inside it*/
<div class="widgetable">
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>russian visa</div><div class="gapper"> </div>
<div class="widgetbars"><span class="centerer"></span>train tickets</div>
</div>
<div class="vertgapper"></div>
<div class="widgetrow">
<div class="widgetbars"><span class="centerer"></span>guide book</div><div class="gapper"></div>
<div class="widgetbars"><span class="centerer"></span>hotels</div>
</div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
<div class="vertgapper"></div>
</div>
</div>
CSS
#container
{
display:flex;
display: -webkit-flex;
display: -moz-flex;
}
#container > * {
flex: 1 ;
}
Hope this helped.. And have a look at flex property of CSS3