H2 and P on same line (HTML, CSS, PHP) - html

Hi i would like to have my h2 heading and p on the same line with 2 empty spaces between them. I have tried almost all solutions but i dont know what im doing wrong. Here is my CSS and HTML:
h3 {
float: right;
padding: 0;
margin: 0;
left: 20px;
display: inline;
color: #00cccc;
}
publish_date {
text-align: left;
padding: 0;
margin: 0;
color: #ff0033
}
<publish_date>Lorem ipsum</publish_date>
<h3>Sit amet</h3>

Test this out!
CSS:
p, h3{
display: inline-block; /* display on the same line */
}
h3{
position: relative;
left: 20px; /* this will not work without setting position property */
padding: 0;
margin: 0;
color: #00cccc;
float: right;
}
p{
padding: 0;
margin: 0;
color: #ff0033
text-align: left;
}
HTML:
<p><?php echo $the_publish_date ?></p><h3><?php echo $article_title1 ?></h3>
Just for your information, as Muhammad Usman stated, "<publish-date> is not a valid HTML tag", and whilst you are able to do this, there is no real point to it. You might as well just stick to the native <p> or <span> tags.
Hope it helps!
JSFiddle: https://jsfiddle.net/n3kmd9ye/

Add to h3 float:left; margin-right:10px;
float:left will put the next to each other and with the margin-right you can control the distance between them.
h3 {
float: right;
padding: 0;
margin: 0;
left: 20px;
display: inline;
color: #00cccc;
float:left;
margin-right:10px;
}
publish_date {
text-align: left;
padding: 0;
margin: 0;
color: #ff0033
}
<publish_date>Lorem ipsum</publish_date>
<h3>Sit amet</h3>

I know this is a bit outdated here but this is the way how I solved it.
Put a wrapper around the two elements like this:
<div class="publish-wrapper">
<publish_date>Lorem ipsum</publish_date>
<h3>Sit amet</h3>
</div>
And then use a flexbox.
.publish-wrapper {
display: flex;
flex-direction: row;
}

Related

Why are my <p> paragraphs appearing on the same line?

I have a basic website and I'm stylizing html with css. I put two paragraphs next to each other and they appear on the same line, although separately as two centered pieces.
For example:
<p>ugh</p>
<p>yay</p>
would show up in the website like
ugh yay
instead of
ugh
yay
The CSS I have for the paragraphs are:
p {
text-align: center;
color: black;
display: block;
font-size: 20px;
margin-top: 0;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
}
NOTE TO EVERYONE: REMOVING INLINE-BLOCK DID NOT FIX IT
FULL CODE CSS: https://jsfiddle.net/sprot9uh/
p {
background: yellowgreen;
text-align: center;
color: black;
display: block;
font-size: 20px;
margin-top: 0;
margin-bottom: 10px;
margin-left: auto;
margin-right: auto;
}
.inline {
display: inline-block;
margin-right: 20px;
background: yellow;
}
<p class="inline">I'm an inline block element....
</p>
<p class="inline"> me too
</p>
<p> But I'm a block level element
</p>
<p>Me too
</p>
remove inline-block for p
p {
text-align: center;
color: black;
font-size: 20px;
margin-top: 0;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
}
That's what the inline-block does in your css. You can either completely remove it or just use block.
add display:block in (p) tag instead of display:inline-block; and u can remove display-inline-block it's also worked...
<p> elements are display: block; by default. Usually all you need is:
p {
margin-bottom: 10px;
font-size: 20px;
color: black;
}
The default display property of p tag is 'block' so you can remove the display property.
You can refer the jsfiddle link
p {
text-align: center;
font-size: 20px;
margin-top: 0;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
}
Looking into your css code I think you have paragraphs <P></P> in <section></section> something like:
<section>
<p>123</p>
<p>456</p>
</section>
You have to change css for section (flex-direction from row to column):
section {
background: white;
color: gray;
padding: 20px;
display: flex;
flex-direction: column;
}

Reposition an h1 tag,

Positioning the <h1> to the position that I want.
Here's what I am trying to do: https://imgur.com/a/D0ief0a
CSS File and HTML File
#import url('https://fonts.googleapis.com/css? family=Montserrat:400,600');
body {
font-family: 'Montserrat';
padding: 0;
margin: 0;
}
.header {
position: relative;
background-color: antiquewhite;
}
.header img {
padding: 1em 2em;
width: 10%;
display: block;
border-radius: 80px;
}
.header h1 {
padding: 1em;
text-align: center;
font-size: 3em;
position: relative;
}
<header>
<div class="header">
<img src="../Welcome/images/123.jpg" alt="">
<h1> A Work In Progress</h1>
</div>
</header>
I tried everything that comes into my mind.
See if it helps :
JSFiddle DEMO
.header img {
padding: 1em 2em;
width: 10%;
border-radius: 80px;
position: fixed;
float: left;
display: inline-block;
}
Added float: left; and position: fixed;, also changed the display to inline-block
I think the best way to do this is use position:fixed:
.header h1 {
text-align: center;
font-size: 3em;
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
This will keep it centered regardless of device coming into your site.
Play the with parameters a bit to get the exact position you want, also you might want to do this to the background aswell.

Why is there more space on the bottom of the div?

I have a header with a div inside of it, for some reason there is more space under the div then above. I tried setting all the padding to 0 in hope to see which one was causing it but it seems to not be a padding at all.
HTML
<header>
<div class="logo">
<div class="centrDivInDiv">
<h1>Welcome to Planet Earth</h1>
<p>The best planet after Pluto.</p>
</div>
</div>
</header>
CSS
body {
margin: 0px;
}
h1 {
margin-bottom: 0px;
}
header {
background-color: #E74C3C;
padding: 10px;
}
header p {
line-height: 0%;
}
.logo {
line-height: 80%;
padding: 10px 20px 10px 20px;
margin: 0px;
background-color: #2C3E50;
display: inline-block;
}
.logo p {
margin-top: 24px;
}
.centrDivInDiv {
display: table-cell;
vertical-align: middle;
margin: 0;
}
JsFiddle
Add vertical-align:middle to your .logo div (and you can remove it from .centrDivInDiv):
.logo {
line-height: 80%;
padding: 10px 20px 10px 20px;
margin: 0px;
background-color: #2C3E50;
display: inline-block;
vertical-align: middle;
}
jsFiddle example
Your problem is caused by the display: inline-block of your CSS. If you remove that or change it for display: blockit will be fine. You should also set your width: 50%
All of that in your .logo
check the fiddle
jsFiddle
The problem exists because you're using display: inline-block; in .logo
The best way to solve this problem is to set font-size to 0 in header so it will be like this:
header {
background-color: #E74C3C;
padding: 10px;
font-size: 0;
}
Also you should set font-size in .logo so it will be like this
.logo {
line-height: 80%;
padding: 10px 20px 10px 20px;
margin: 0px;
background-color: #2C3E50;
display: inline-block;
font-size: 16px;
}
Maybe this link will help you, it has more details
Fighting the Space Between Inline Block Elements | CSS-Tricks

Remove white spaces between img

i'm using blogger and I want to know how can I remove the white spaces between a img and a text, because is a lot separated. Blogger contains a class called separator but I don't know what to do for fix that.
Here's a image:
How can I remove it?
This is my css
.separator{
margin: 0;
display: block;
padding: 0;
}
.post img {
display: block;
text-align: center;
padding: 0px;
margin: 0px;
}
CSS
/* Posts-----------------------------------------------*/
h2.date-header{margin:1.5em 0 .5em;display:none;}
.wrapfullpost{display: block;}
.post{
display: block;
margin: 0;
}
.post img {display: block;
margin: auto;
text-align: center;
padding: 0;
}
.post-title{color:#333333;margin:0 0 10px 0;padding:0;font-family:Arial,Helvetica,Sans-serif;font-size:24px;line-height:24px;font-weight:bold;}
.post-title a,.post-title a:visited,.post-title strong{display:block;text-decoration:none;text-decoration:none;}
.post-title strong,.post-title a:hover{text-decoration:none;}
.post-body{
font-size: 17px;
display: block;
margin: 0;
}
.entry-content{ padding: 0; margin: 0; display: block;
}
.separator{
margin: 0;
display: block;
padding: 0;
}
.post-footer{margin:5px 0; font-weight: 300;}
.comment-link{margin-$startSide:.6em}
.postmeta-primary{color:#999;font-size:12px;line-height:18px;padding:0 0 5px 0}
.postmeta-secondary{color:#999;font-size:12px;line-height:18px;padding:0 0 10px 0}
.postmeta-primary span,.postmeta-secondary span{padding:3px 0 3px 20px;background-position:left center;background-repeat:no-repeat}
.meta_date{background-image:url(http://2.bp.blogspot.com/-paWPYJvQDqA/UC7eiuIKgUI/AAAAAAAAAvw/af410sUcO2w/s000/date.png)}
.meta_author{background-image:url(http://3.bp.blogspot.com/-reTaoyVmDXA/UC7ejgVBQbI/AAAAAAAAAv4/u6d-iPeLZi0/s000/author.png); border-right: 1px solid #ccc;
padding-right: 10px!important;
m
argin-right: 5px;}
.meta_comments{background-image:url(http://2.bp.blogspot.com/-zZgvwATiF3E/UC7ej-cvmbI/AAAAAAAAAwA/THMs0579MII/s000/comments.png) }
.meta_edit{background-image:url(images/edit.png)}
.meta_categories{background-image:url(http://1.bp.blogspot.com/-g-ptS39XbNM/UC7ekTJsEXI/AAAAAAAAAwI/t8fMhUuUvQI/s000/category.png)}
.meta_tags{background-image:url(http://3.bp.blogspot.com/-fZuK3yymXmo/UC7ek6kEDLI/AAAAAAAAAwQ/-J16r4bHvFo/s000/tags.png)}
.readmore{margin-bottom:5px;float:right}
.readmore a{color:#F85B48;background:#EAEAEA url(http://4.bp.blogspot.com/-m6AJDK0k2xA/UC7emOYbEbI/AAAAAAAAAwY/Q4o73QiZdc4/s000/readmore-bg.png) left top repeat-x;padding:8px 14px;display:inline-block;font-size:12px;line-height:12px;text-decoration:none;text-transform:uppercase}
.readmore a:hover{color:#fff;background:#E74F3D url(http://4.bp.blogspot.com/-m6AJDK0k2xA/UC7emOYbEbI/AAAAAAAAAwY/Q4o73QiZdc4/s000/readmore-bg.png) left -126px repeat-x;text-decoration:none}
And this is what blogger add in HTML
<div class="separator" style="clear: both; text-align: center;">
<img border="0" src="http://3.bp.blogspot.com/-DGgnyTkp3xc/VAtkSdWZLxI/AAAAAAAAAb4/oXctHDcrSRk/s1600/Sinopsis%2Bwissar.png" height="160" width="640" /></div>
Since you didn't share any of your code, It's hard to explain where is the problem (You may get negative rep).
but i can suggest you to look at your style classes. try following, it's just a removal of Padding, and Margin
.imageClass{
padding: 0px;
margin: 0px;
display: block;
}
.textClass{
padding: 0px;
margin: 0px;
display: block;
}
Within the seperator class there is a blockquote which contains the text, and an a tag which is a link containing the image. Both of these have margins that you do not want. Try this.
.seperator blockquote {
margin: 0px;
}
.seperator a {
margin-right: 0px;
}
Note: Remove what was in my previous answer.
If you can't get it to work, go to the section on your webpage that you want to change, right click -> inspect element. This will bring up the HTML inspector. You can then click on different elements and see the css on the right hand side that relates to that element. Try unticking different css statements or changing them/adding new ones. Just continue to play around with it until you can get it. I really can't be of any more help.
Solved, just added the next
.separator {
display: block;
line-height:0;
margin: 0;
padding: 0;
}
.separator blockquote {
margin: 0;
}
.separator a {
margin-right: 0;
}
Thanks to Yep_It's_Me who helped me a lot.

Horizontally center text in <p> display: table-cell?

I'm trying to center the text horizontally, but it doesn't work. It seems to be because of the display: table-cell
Would you know a work around? (note that I'm using bootstrap)
Thanks! > Codepen: http://codepen.io/goodux/pen/wgBCf
html:
<div class="feature">
<span class="glyphicon glyphicon-star feature-icon"></span>
<p class="feature-text text-center">
Gather user's feedback and engineer's requirements.
</p>
</div>
css:
.feature {
margin-bottom: 3.5em;
background-color: #f3f3f3;
border-radius: 5px;
}
span.feature-icon {
background-color: #FA6900;
border-radius: 3px;
color: #FFF;
font-size: 3em;
padding: .5em;
position: absolute;
top: 0;
}
p.feature-text {
overflow: hidden;
padding: 0 .5em 0 6.5em;
vertical-align: middle;
height: 6em;
display: table-cell;
}
.text-center {
text-align: center;
}
For display:table-cell to work correctly it needs to be inside a display:table element.
So, if you change the .feature rule to
.feature {
margin-bottom: 3.5em;
background-color: #f3f3f3;
border-radius: 5px;
display:table;
width:100%;
}
it will work as expected: http://codepen.io/gpetrioli/pen/EDtCq
of course you could avoid using display:table-cell if it is not really needed. (and in your example it looks like it is not..)
Try p {text-align: center;margin: auto }and why are you using display:table-cell ?