Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
How can I vertically align text inside the div with the image?
Fiddle: http://jsfiddle.net/C6pf7/3/
EDIT: I cannot use display:table; or height for div1
I tried putting the image as a background in the div that's one way of sort of doing it. Although you can use
vertical-align:middle
Heres a link to question already asked previously.
Vertically align text next to an image?
Use below Code:
<div id = "div1" style='float:left;width:100%'>
<p align='left' >
<img src="http://www.loriswebs.com/html-tips/images/delphinium-close1c.jpg"
id= "img1" style='float:left;'></img>
123
</p>
</div>
Set min-height: for #div
Like
#div1{
text-align: center;
vertical-align : middle;
border: 2px solid red;
min-height:80px;
}
Use line-height:75px in your css and add a new div with style="clear:both;"
Css:
#div1{
text-align: center;
vertical-align : middle;
border: 2px solid red;
line-height: 75px; /* Add this */
}
Updated Fiddle
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a rectangular-shaped gray div that is supposed to hold a header ("sample text") and a thin turquoise highlight (which is also just a thin rectangle). When I have both the turquoise div and header inside the other div, one gets forced out.
First of all, how can I fix this issue? Also, is there a more efficient way for me to make the turquoise highlight in the gray div?
http://imgur.com/Sm8qy8J,kSuNEh5 (if I have HTML as shown)
http://imgur.com/Sm8qy8J,kSuNEh5#1 (if I remove the turquoise div)
<div class="column w2">
<div id="headerbox">
<div class="highlightbox">
</div>
<h3>sample text</h3>
</div>
</div>
Note I'm using some Sass CSS here:
h3 {
font: $header-type-font;
font-family: $header-type-font;
color: $header-type-color;
text-align: center;
}
#headerbox {
background-color: $box-color;
height: $block-height;
width: 400px;
}
.highlightbox {
background-color: $highlight-color;
height: $block-height;
width: 20px;
}
Add float:left to your highlightbox class:
.highlightbox {
background-color: $highlight-color;
height: $block-height;
width: 20px;
float:left;
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
The idea is, in a table, inside a td put a line in the middle of such, like this:
That you can write in it and the line stays there, like a "line background", but inside the td
Any ideas?
There are many ways
1) Add HTML <strike> or <del>.
2) use css property, text-decoration: line-through;
3) Using CSS:
td{
border: 1px solid black;
position: relative;
}
td:after{
content: "";
display: block;
width: 100%;
height: 1px;
background-color: black;
position: absolute;
top: 50%;
}
Working Fiddle
EDIT: Since there is a bug in firefox related to position: relative and td element, wrap the text in a div of each td and use the same above css.
Working Fiddle
EDIT 2: In the comments below, #NicoO showed that the firefox bug can be resolved by giving line-height: 0 to the tr element.
Working Fiddle
Here is the working one - Result Fiddle
HTML
<td><i class="line"></i>This Is demo Text</td>
CSS
.line{
width:100%;
height:0;
border-bottom:1px solid #111;
float:left;
margin:0;
position:absolute;
z-index:0;
top:50%;
left:0
}
You can try to create an image (1px width and height of your td) and use background-image property in css like this:
td{
background-image: url('relative/path/to/your/image');
}
I just tested doing it with a span, and it worked, but other solutions might be much more elegant.
http://codepen.io/anon/pen/GAlFr
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I am looking at generating the below image using CSS.
I've tried adding all the required information needed below.
The BgColor, Font-Color, Font Size, Font Family, Font Style. Please mention if any other data is needed.
The Font Text should be displayed in the middle of the image. How do I build CSS to get the text in the centre.
HTML
<div>WW</div>
CSS
div{ background:#ced6e9;
font:bold 46px arial; color:#315bb4;
width:100px; height:100px; line-height:100px;text-align:center}
Here is the Demo http://jsfiddle.net/9Dxza/1/
horizontal centering:
text-align : center;
vertical centering:
line-height : 100px;
background-color: green;
height: 35px;
width: 35px;
text-align: center;
line-height: 35px;
font-size: 18px;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have the following page:
Page on JSBin
If you look at the top-right-hand corner, then you can see that the settings & chat pic and the username is aligning with the lower border of the profile picture.
How could I make all elements in top-right-hand-corner align in the middle of the top-bar?
The top-bar is supposed to look like that:
EDIT: I have applied the vertical-align: middle property to these elements. However, as you can see at ranganadh's JSBin, the image seems to be a bit too near to the lower corner. Any suggestions on that?
add vertical-align:middle property to class .top-right-button
change to
.top-right-button{
margin-right: 5px;
vertical-align:middle
}
Check JSBin
You need to modify your CSS as follows:
.right-stuff {
position: absolute;
bottom: 2px;
height: 100%;
right: 0px;
font-family: Roboto Condensed, bold;
font-size: 24px;
}
.top-right-button {
margin-right: 5px;
vertical-align: middle;
}
The vertical-align property is not inherited and must be specified explicitly.
By default, your right most image is aligned with the default baseline of the container block. Setting vertical align to middle gives a more pleasing view.
If you need to, use the bottom offset to adjust the overall vertical position of the .right-stuff block.
See demo at http://jsbin.com/uSiTOpU/16/edit
I hope i understand your edit well.
Try to change
#top-right-profile-image {
margin-top: 5px;
width: 40px;
height: 40px;
background-color: #ffffff;
}
to
#top-right-profile-image {
width: 40px;
height: 40px;
background-color: #ffffff;
}
It gives a better looking result.
I believe you simply need to add an valign="top" to your profile image.
<img valign="top" class="top-right-button" id="top-right-profile-image" src="//www.placehold.it/20x20"/ >
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I would like for the number and the word members to be aligned.
What am I doing wrong?
Link here
Add float:left to id stat-left
Check this updated DEMO
#stat-leftgive to`
display:inline-block
as like this
#stat-left {
display:inline-block;
vertical-align:top;
}
Demo
Add style="float:left" to the div with number :)
It will allow next Divs to float object from left side :)
<div id="connections">
<div id="stat">
<div style="float:left"id="stat-left">
<p span class="number"> 2,476 </p>
</div>
<div id="stat-right">
<p> Followers </p>
</div>
</div>
</div>
You could quite easily condense your code. Rather than using a paragraph tag, why not use a span instead? Paragraph tags are automatically block level elements, but spans are inline by default.
jsfiddle.
i tried to make a code for your with only one div and minimize code
HTML
<div id="connections">
<p class="number"> 2,476 </p>
<p class="stat-right">Followers </p>
</div>
CSS
#connections {
margin: 0px;
width: 150px;
font-family: calibri;
font-size: 22;
color: #444;
border:1px solid red;
overflow:hidden;
}
.number {
margin: 0px;
padding: 0px;
float:left;
}
.stat-right {
float:right;
margin-top:7px;
}
Check the demo :- http://jsfiddle.net/EC63P/35/