Align the two <p> element in the same line - html

This is the Demo.
I want to align the two <p> element in the same line, but you can see the second one moves down a little bit. Anybody knows the reason?
HTML
<div class="logo">
<p>Hello world</p>
<p class="web_address">Hello all</p>
</div>
CSS
.logo p {
margin:0;
padding:0;
border: solid 1px black;
margin-left: 20px;
font-size: 36px;
display: inline-block;
line-height: 80px;
}

Inline(-block) elements (the paragraphs in this case) are aligned vertically in their baseline by default. You could add vertical-align: top; to fix the alignment issue.
Updated Demo.
.logo p {
/* other styles goes here... */
display: inline-block;
vertical-align: top;
}
For further details you can refer this answer.

<span> might be a better solution:
http://jsfiddle.net/Zxefz/
<div class="logo">
<span>Hello world</span>
<span class="web_address">Hello all</span>
</div>
.logo{
height: 80px;
border:1px solid red;
}
.logo span{
margin:0;
padding:0;
border: solid 1px black;
margin-left: 20px;
font-size: 36px;
display: inline;
line-height: 80px;
}
.logo .web_address{
font-size:26px;
}

the following worked for me:
.toptext {
display: flex;
align-items: center;
}
<div class="toptext">
<p>Please ensure all original documents requested are enclosed</p>
<p id="right">Claim Reference No.: <input type="text" name="" value=""></p>
</div>

Related

cannot align text next to image with proper intent

Hello i am trying to make an footer it have an image so i am not able to properly intent my webpage please help... I want to achieve something like this::
CodePen link :https://codepen.io/Sherrinford03/pen/yGKaQb
What i want
how far i have come
<div class="footer">
<div class="part">
<div class="body_of_part">
<img src="images/brochure.jpg" align="bottom">
</div>
</div>
<div class="part">
<div class="body_of_part">
<span class="Title_of_departments">ADDRESS</span>
<span class="Body_of_cap">SOMEADD</span>
</div>
</div>
<div class="part">
<div class="body_of_part">
<span class="Title_of_departments">Contact us</span>
<span class="Body_of_cap">
Email<br>
SOMEMAIL
</span>
</div>
</div>
</div>
...CSS
.footer{
display: table;
text-align: center;
margin:20vh 0vw 0 0 ;
padding:0 0 0 0;
background: #222222;
}
.part img{
vertical-align: middle;
display: table-cell;
width: 20vw;
}
.footer .part{
height: 40vh;
border-left: 1px solid #353535;
display: inline-block;
width:20vw;
}
.part .Body_of_cap{
font-size: 18px;
}
Can u please help me ! i have been looking for a solution for about 2 hours ... PLease help!
remove
inline-block
from
.footer .part{
and it should work
I think I got it, I modifierd 3 css classes:
.footer{
/*display: table;*/
text-align: center;
margin:20vh 0vw 0 0 ;
padding:0 0 0 0;
background: #222222;
height: 300px
}
.footer .part{
height: 40vh;
border-left: 1px solid #353535;
/*display: inline-block;*/
width:20vw;
/*display:table-cell; vertical-*/
display: inline-block;
align:top;
}
.Title_of_departments{
display:block;
font-family: "Sofachrome" !important;
font-size: 20px;
/*padding:20vh 0vh 5vh 0vh;*/
text-align: center;
color: #E50000;
}
https://codepen.io/lolpez/pen/zyWoxL

Display an image with a div which can wrap the link

I am working on a simple html/css web page.
What I am trying to do is having an image and a div. Both will be inline display and in div I want to put a link. But when I put a long link title it is not what I expect it to be.
My code is this-
code
<div class="heading"> featured posts
</div>
<div class="img_src">
<img style="height:120px;" src="/uploads/1.jpg"></img>
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
CSS-
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
line-height: 120px;
width: 61%;
margin-top: 3px;
text-transform: uppercase;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
I searched on google and StackOverflow but I did not get anything useful.
I want it to look like this(DIV wraps full)-
Any suggestion?
You csn use diplay:table-cell instead of inline-block but also I made edit in html by adding div.post that contain the image and title, and remove the inline-style that gave height to the image
<div class="post">
<div class="img_src">
<img src="http://i.dailymail.co.uk/i/pix/2016/03/22/13/32738A6E00000578-3504412-image-a-6_1458654517341.jpg">
</div>
<div class="link_src">
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
</div>
and in the css I give width:20%; to .img_src and width:80%; to .link_src (you can change the widths as you like) and remove height and line height from them and the diplay:table-cell will handle those height
.post{
font-size:0;
display:table;
width:100%;
}
.img_src{
display: table-cell;
vertical-align:top;
width:20%;
}
.img_src img{
width:100%;
}
.link_src{
display: table-cell;
background-color: white;
margin-top: 3px;
text-transform: uppercase;
vertical-align:middle;
width:80%;
}
.inside_link{
margin-left: 2%;
margin-right: 2%;
font-size: 15px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
https://jsfiddle.net/IA7medd/gg7ygdLs/17/
You can achieve that by changing the inline-block display to table-cell and then apply the vertical-align:middle; property on the text container.
That way, the text will be perfectly vertically centered if there are one, two, three lines of content.
.parent{
display: table;
border: 5px solid #ccc;
width: 100%;
}
.img_src{
display: table-cell;
}
.link_src{
display: table-cell;
vertical-align: middle;
background-color: white;
width: 61%;
text-transform: uppercase;
}
See this fiddle
Ok you are using the wrong approach. Line height is causing you the problem. Your html should look like this
<img class="img_src" style="height:120px;" src="/uploads/1.jpg">
<div class="link_src">
<div class="inner_link_src">
<div class="inner_margin">
Link will go here but if there is a long title then it may create some problems..
</div>
</div>
</div>
and your css like this
.img_src{
float:left
}
.link_src{
float:left;
position:relative;
width: 61%;
text-transform: uppercase;
background-color: white;
vertical-align: top;
display:table;
height:120px;
}
.inner_link_src{
display:table-cell;
width:100%;
height:100%;
vertical-align:middle;
margin-left:10px;
}
.inner_margin{
margin-left:10px;
}
see the jsfiddle it is working great
https://jsfiddle.net/gg7ygdLs/27/
You just change your CSS and HTML by following and then you get the desired result.
CSS:
.img_src{
display: inline-block;
margin-top: 3px;
margin-left:-2%;
}
.link_src{
display: inline-block;
background-color: white;
height: 120px;
width: 100%;
margin: 10px 0 10px 3px;
-webkit-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
-moz-box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
box-shadow: 7px 0px 0px 3px rgba(204,204,204,1);
}
.inside_link{
margin: 2%;
display: inline-block;
position:absolute;
padding: 8px;
}
.heading{
display: block;
background-color: #000;
color: #fff;
font-family: "Roboto Condensed","HelveticaNeue-CondensedBold","Helvetica Neue",Helvetica,Arial,Geneva,sans-serif;
font-size: 20px;
margin-top:5px;
font-color:white;
margin-left:-2%;
margin-right:-2%;
text-align: center;
line-height: 40px;
height: 40px;
font-style: oblique;
text-transform: uppercase;
}
HTML:
<div class="heading"> featured posts
</div>
<div class="link_src">
<img style="height:120px;" src="http://smashinghub.com/wp-content/uploads/2011/11/Text-Shadow-Box.jpg" />
<a class="inside_link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</div>
Demo
You can simplify your code a lot by using Flexbox.
You can use it for your header as well, to center the title.
.your-header {
display: flex;
align-items: center;
justify-content: center;
}
Then the image container. Use it's more semantic and it's a block element, perfect to wrap an image with a caption or a link in your case:
<figure class="your-figure">
<img class="your-image" src="http://pipsum.com/200x150.jpg"></img>
<a class="your-link" href="#">Link will go here but if there is a long title then it may create some problems..</a>
</figure>
and the CSS
.your-figure {
display: flex;
align-items: center;
padding: 4px;
border: 1px solid #ccc;
background-color: #fff;
}
.your-image {
margin-right: 10px;
}
Have a look here for the complete code ;)
Follow this if you don't know Flexbox, might seems daunting at first, but when it clicks in your head it will change your life :) Complete guide to Flexbox

How to align div boxes responsive in html?

I have tried to get responsive design for div boxes. But couldn't get it.
I got output like this..
When I tried to expand it, it is showing like this.
Couldn't get responsive one...
Tried with ctrl+shift+m in firefox.
Here is my code
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
.tab_list_common{
font-family: Arial;
font-size: 13px;
font-weight: bold;
color: #666666;
line-height: 1.3;
border: 1px solid #000000;
display: inline-block;
}
.com_div{
text-align: center;
width: 100%;
}
.outer{
border: 1px solid #000000;
line-height: 50px;
width: 100%;
text-align: center;
}
</style>
</head>
<body>
<div class="outer">
<div class="com_div">
<span class="tab_list_common">$1.00</span>
<span class="tab_list_common">$2.00</span>
<span class="tab_list_common">$3.00</span>
<span class="tab_list_common">$4.00</span>
</div>
</div>
</body>
</html>
You have to display them as inline-block, eliminate white spacing between them and set width to: (total width / elements).
Setting box-sizing: border-box; would include borders in width calculation.
Edit: Added spacing between divs using margin.
.tab_list_common{
font-family: Arial;
font-size: 13px;
font-weight: bold;
color: #666666;
line-height: 1.3;
border: 1px solid #000000;
display: inline-block;
width: 20%; /* total width / elements */
margin: 0 2.5%;
display: inline-block;
box-sizing: border-box;
}
.com_div{
text-align: center;
width: 100%;
}
.outer{
border: 1px solid #000000;
line-height: 50px;
width: 100%;
text-align: center;
}
<div class="outer">
<div class="com_div">
<span class="tab_list_common">$1.00</span><!--
--><span class="tab_list_common">$2.00</span><!--
--><span class="tab_list_common">$3.00</span><!--
--><span class="tab_list_common">$4.00</span>
</div>
</div>
Try this JSFiddle
This technique uses text-align:justify; on the .outer div, which applies to the the inline-block elements.
CSS
.outer {
border: 1px solid #000000;
width: 100%;
text-align:justify;
-ms-text-justify:distribute-all-lines;
text-justify:distribute-all-lines;
min-width:13em; /* add this if you don't want the divs to wrap when the screen size is reduced */
}
.com_div {
padding:.95em .95em 0em .95em;
line-height:1;
}
.tab_list_common {
font-family: Arial;
font-size: .82em;
font-weight: bold;
color: #666666;
border: 1px solid #000000;
display: inline-block;
vertical-align:top;
}
.stretch {
width:100%;
display:inline-block;
font-size:0;
line-height:0;
}
HTML
<div class="outer">
<div class="com_div">
<span class="tab_list_common">$1.00</span>
<span class="tab_list_common">$2.00</span>
<span class="tab_list_common">$3.00</span>
<span class="tab_list_common">$4.00</span>
<span class="stretch"></span>
</div>
</div>
It requires a span div at the bottom for stability, and the divs need to be on their own line, or have a space between the tags. For more useful justify centering techniques see this Stack Overflow question.

Arrange DIVs in another DIV

This is my HTML code:
<div id="upmenu">
<div class="info" id="info-uberuns"><div>ubernus</div></div>
<div class="info" id="info-consultant"><div>consultant</div></div>
</div>
And this is CSS class:
.info{
position: absolute;
width: 130px;
height: 47px;
z-index: 0;
background: rgba(255,255,255,0.8);
top: 13px;
color: #3b3b3b;
padding-top: 5px;
line-height: 22px;
font-size: 15px;
cursor: pointer;
}
.info div{
margin-left: 20px;
}
#upmenu{
margin:auto;
width:100%;
}
I want to arrange DIVs with info class in the DIV with upmenu class and show them side by side.
But the problem is that they are shown on top of each other instead of being shown side by side.
Please help me to solve this issue.
Regads
Try adding the following to the .info class.
display: inline-block;
vertical-align: top;
Also remove position: absolute; from .info
http://jsfiddle.net/G3N24/
You can add float:left to the .info class.
Either you can make the div's display property as inline-block like mituw16 showed,
OR
You can make the element itself a span, and no need to change any style.
<div id="upmenu">
<span class="info" id="info-uberuns">ubernus</span>
<span class="info" id="info-consultant">consultant</span>
</div>
JSFIDDLE
A different approach...not any better than other suggestions.
FIDDLE
You can play with the CSS and make it look anyway you want.
HTML
<div id="upmenu">
<div class="info" style="float: left;" id="info-uberuns">
ubernus
</div>
<div class="info" style="float: right;" id="info-consultant">
consultant
</div>
</div>
CSS
#upmenu{
border: 0px solid black;
margin:20px auto;
width:40%;
}
.info{
background-color: blue;
color: white;
padding: 10px;
line-height: 22px;
font-size: 15px;
cursor: pointer;
border-radius: 5px;
}

How do I center this element?

My HTML:
<div class="container">
<div class="card login">
<p id="Title">Plex</p>
<div class="label">
</div>
Random text
</div>
<div class="card welcome">
<div class="label">
<p id="Title">Hi!</p>
</div>
Lorem ipsum
</div>
<div class="card extra">
<div class="label">
<p id="Title">Extra</p>
</div>
Lorem ipsum
</div>
</div>
MY CSS:
.container{
display: flex;
width: 100%;
/*align-content: center;*/
}
.card {
flex: 1 1 auto;
border: 1px solid #f3f3f3;
background-color: #f3f3f3;
margin-left: 50px;
margin-right: 50px;
margin-top: 25px;
height: 450px;
}
.label{
background-color: #434342;
width:auto;
height: 70px;
}
.card:not(:first-child){
margin-left: 20px;
}
#Title {
float: left;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
A JSFiddle: http://jsfiddle.net/cvYGW/
How do I make the PLEX HI EXTRA all align perfectly in the middle of their cards and how do I move them up or down?
You have to reset margin to 0 for #title and put a line-height that equals to the height of the parent.
#title { /* change this selector to .title */
line-height: 70px;
margin: 0;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
See: http://jsfiddle.net/cvYGW/9/
By the way, remember that your code is not valid HTML, as you use the same ID three times (#title). You should use class in this case. And you don't need any float property.
You shouldn't have multiple instances of an ID, so firstly change #Title to a class
You can't use float:left; & text-align:center;, remove the margin from your title p, match the line height
.title {
margin:0px;
line-height:70px;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
http://jsfiddle.net/cvYGW/6/
#Title {
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
margin:0 auto;
}
I have update the js fiddle
you just have to add
#Title {
line-height:70px;
width:100%;
margin:0;
}
Check on fiddle
Please refer below updated fiddle
http://jsfiddle.net/cvYGW/10/
give some width for parent div and align the child elements in center of parent by using margin css property.
margin: 0 auto;
Thanks,
Siva
Check out http://jsfiddle.net/skyrbe/cvYGW/8/
You were using same id for multiple p tags . Never do that.
.Title {
float: left;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
width:100%;
margin:0px auto;
line-height:42px;
}
update css:
#Title {
float: left;
font-family: Thinfont-Thin;
font-size: 20px;
color: #d2731d;
text-align: center;
width: 100%;
}
jquery animation
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$('#Title').click(function(){
$('#Title').animate({
bottom: '-=20'
}, 1000);
});
});
updated fiddle