CSS text starting from a wrong place - html

This might be a stupid question, but it has been troubling me a lot.
I have made 4 boxes and each box should have the text starting from a same line, but sometimes (when the text is less), it starts from the bottom.
Here's the image displaying it:
Ideally, it should start from the top and go till the bottom. Like this:
What changes should I make in my CSS code?
CSS :-
.show-text {
margin-left: 264px;
float: left;
font-size: 15px;
width: 15em;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
color: #606060;
}
.show-text-col-2 {
display: inline-block;
margin-left: 20px;
font-size: 15px;
width: 15em;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
color: #606060;
}
.show-text-col-3 {
display: inline-block;
margin-left: 20px;
font-size: 15px;
width: 15em;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
color: #606060;
}
.show-text-col-4 {
display: inline-block;
margin-left: 20px;
font-size: 15px;
width: 15em;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 18px;
color: #606060;
}
My JSFiddle :- http://jsfiddle.net/xa0obvyr/

Because you are using inline-block, you need to specify vertical alignment if the default value doesn't suit you. In this case, you need
show-text-col-4 {vertical-align: top;}
However, your setup is less than ideal. Rather than floating the first time with a large left margin, I'd recommend you use a centered wrapper element instead, and style each of the columns in the same way.

This is what you need? with one CSS class and automatic 1/4 width of each column.
Please check the demo: http://jsfiddle.net/sk1rqxeo/
.show-text-col {
float: left;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
line-height: 18px;
color: #606060;
width:24.5%;
display: inline-block;
}

You will need to set width to <p> tag
FIDDLE DEMO
.show-text-col-3 p{
width:200px;
}

Related

apply style to a div in just 1 page

I have the below style:
.field.field--name-name.field--type-string.field--label-hidden.field__item.quickedit-field {
position: relative;
z-index: 200;
display: block;
float: left;
max-width: 200px;
background: #a02853;
font-family: 'Open Sans', Arial, "Helvetica Neue", Helvetica, sans-serif;
color: #FFF;
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
line-height: 100%;
padding: 5px;
font-size: small;
I want to apply this to div in /blog/* pages alone. How to do this?
The div I'm trying to apply this to:
<div data-quickedit-field-id="taxonomy_term/2695/name/en/default" class="field field--name-name field--type-string field--label-hidden field__item quickedit-field">Term1</div>
we have several solutions for this question. first of all you have to set unique class into body tag and call the body class before .field.field--name-name.field--type-string.field--label-hidden.field__item.quickedit-field
Secondly, you have to use a specific id for element and you use it in style but I don't recommend using it.

CSS - aligning H1 with a span symbol

I'm styling the section headings for a website and I can't quite get a span symbol and a H1 heading to align properly. This is how it looks on the site -
Annoyingly, when I've come to include the code in this snippet the two elements seem to align. When I check the console the span element seems to have a buffer around the symbol which prompts it slightly out of line as you can see in the image. I'm using bootstrap for the site, could this be a hidden rule that I'm missing?
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 20px 20px;
}
.secthead h1, span {
display: inline-block;
}
<div class="secthead"><span style="color: rgb(255,128,55);">+</span><h1>Who We Are</h1></div>
Just use vertical-align: middle; in both tag & remove padding from bottom in h1 tag. check updated snippet below..
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 0px 20px;
}
.secthead h1, span {
display: inline-block;
vertical-align: middle;
}
<div class="secthead"><span style="color: rgb(255,128,55);">+</span><h1>Who We Are</h1></div>
You could use a height and line-height.
.secthead span {
font-weight: bolder;
font-size: 80px;
font-family: 'Gotham-Medium', sans-serif;
}
.secthead h1 {
margin: 0;
font-size: 50px;
font-family: 'Gotham-Medium', sans-serif;
color: #000;
text-align: left;
padding: 0 0 20px 20px;
line-height: 92px;
}
.secthead h1, .secthead span {
height: 92px;
display: inline-block;
vertical-align:top;
height: 92px;
}
<div class="secthead">
<span style="color: rgb(255,128,55);">+</span>
<h1>Who We Are</h1>
</div>

How to Create paragraph first letter uppercase in html & css (in special format)

Please help me to create this format of paragraph in html & css
CSS and HTML:
.home-p-main {
font-family: Times New Roman;
font-size: 10pt;
text-align: left;
position: relative;
margin-left: 10pt;
margin-right: 10pt;
position: absolute;
margin-top: 1pt;
color: black;
background-color: aliceblue;
text-indent: 10pt;
}
.home-p-main::first-letter {
text-transform: capitalize;
color: red;
font-size: 300%;
font-weight: bold;
padding-left: 25px;
position: relative;
margin-left: -26px;
}
<p class="home-p-main">The Linux open source operating system, or Linux OS</p>
Just with html and css
I am guessing that the problem is that the first letter stays on the first line, and the second line underneath it. And you would like the second (and so on) to be on the right of the first letter.
You could do so, by displaying that first letter as a block, and float it to the left.
The CSS then looks like this (removed unnecessary lines)
.home-p-main{
font-family: Times New Roman;
font-size: 10pt;
margin-left: 10pt;
margin-right: 10pt;
margin-top: 1pt;
background-color: aliceblue;
}
.home-p-main:first-letter{
text-transform:capitalize;
color: red;
font-size: 500%;
font-weight: bold;
display: block;
float: left;
margin-right: 5pt;
}
DEMO
CSS
.home-p-main{
font-family: Times New Roman;
font-size: 10pt;
text-align: left;
position: relative;
margin-left: 10pt;
margin-right: 10pt;
position: absolute;
margin-top: 1pt;
color: black;
background-color: aliceblue;
width:100px;
}
.home-p-main::first-letter{
font-size: 300%;
float: left;
height: 64px;
margin-right: 10px;
color: rgb(245, 10, 10);
border-radius: 5px;
}
For this to work as you wished you have to remove text-indent from .home-p-main class and if you wish the words to be aligned perfectly in-spite of break letters use word-break: break-all; in the .home-p-main class
DEMO
There's a property for that:
.home-p-main {
text-transform: capitalize;
}
If you want the first letter of the first word to be uppercase, use :first-letter with a different transform instead (although it doesn't really matter). Note that in order for :first-letter to work your a elements need to display as blocks:
.home-p-main {
display: block;
}
.home-p-main:first-letter {
text-transform: uppercase;
}

Why can I get no satisfaction trying to add margin or padding between an image and some text?

I want an image on the left and three pieces of text on the right. I've got that, but trying to add some space between them is proving to be an exercise in futility. I've tried adding both padding-left and margin to the css, but they ignore them like a cheerleader does a nerd.
The jsfiddle is here: http://jsfiddle.net/GwYJH/
Here's my HTML:
<a id="mainImage" class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/1456334050" rel="nofollow noreferrer"><img height="200" width="160" src="http://ecx.images-amazon.com/images/I/51ETjedyMAL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA300_SH20_OU01_.jpg"></img></a>
<div class="category">Picaresque Satire</div>
</br>
<div class="title">the Zany Time Travels of Warble McGorkle</div>
</br>
<div class="author">Blackbird Crow Raven</div>
</br>
...and the CSS:
body {
background-color: black;
}
.floatLeft {
float: left;
}
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25;
margin: 25;
}
.title {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
}
.author {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
}
I also want each piece of text to wrap if the viewbox narrows. IOW, "Picaresque Satire" should become:
Picaresque
Satire
...if there's not enough space to fit on one line; what it's doing now is moving below the image if it runs out of space (then it will break as I want it to if it gets squished even more).
#mainImage {
margin-right:15px;
}
.category p {
word-wrap:break-word;
}
Demo here:http://jsfiddle.net/GwYJH/8/
How the word wraps (i.e. if it wraps to the right hand side of the image or below it) is wholly dependent on the width of the containing element.
I have some suggestions for you. Fist of all, use this code to get the spaces.
.floatLeft {
float: left;
padding-left: 25px;
margin: 25px;
}
The, set the width to the .category, so you wrap the text
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25;
width:30px;
}
jsfiddle
Non-zero padding and margin values require a unit to be specified. I assume you wanted pixels:
padding-left: 25px;
margin: 25px;
http://jsfiddle.net/GwYJH/6/
Old versions of IE would allow you to omit the unit, but modern standards compliant browsers do not.
You dont have (px) defined on the padding-left and margin. Remove margin and only use padding-left on all of the divs.
Use this code instead:
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
padding-left: 25px;
}
.title {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
padding-left: 25px;
}
.author {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
padding-left: 25px;
}

Center the text of an inline-block

I need to center the text in one of my inline-block button. How might I go about accomplishing this? Any help will be appreciated.
Source Code:
CSS:
.dropMenu
{
color: #FFFFF0;
text-decoration: none;
display: inline-block;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 80%;
text-align: center;
}
.dropMenu:hover,
.dropMenu.selected
{
background-color: #544E4F;
}
HTML:
dropMenu
Without vertical-align : middle:
http://img140.imageshack.us/img140/7476/withoutt.png
With:
http://img834.imageshack.us/img834/904/withe.png
I've just find the solution by adding a label and changing his css:
Button
<label for="dropDown">Menu</label>
Css
label
{
padding: 0 5px 0 5px;
vertical-align:super ;
}
.dropMenuButton
{
color: white;
text-decoration: none;
display: inline-block;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 80%;
padding: 5px 5px 5px 5px;
}
If you know for sure that your options are going to fit on one line per option, you can use the line-height property to set the height and the text will automatically be vertically centered.