Vertical centering element CSS - css

In below code how do I do vertical center element span with class "ExclamationPoint" ?
I want to design it like below picture :
I tried Padding-top and vertical; align but I couldn't style like image
I want to position span with class "ExclamationPoint" vertically middle regardless the height of side DIV.
JSFiddle Link

You can force it to the middle of the div like so:
First make sure the parent div (NewsNote) has a position set, so add position:relative;.
Now, you can center .ExclamationPoint by giving it a height of 0, position:absolute; and top:50%;. This will push the div down to the exact middle.
Now the exclamation point will be below the center, to fix this add line-height:0;.
http://jsfiddle.net/vNDUx/1/

Related

CSS text-align:center is incompatible with position

i'm trying to fix the position of a div while this div's alignment is centered, but when i enter position (whether fixed or absolute) alignment to center is disturbed. what's the cause?
#stage {text-align: center; position:fixed;}
You need to define a width for the fixed-position element. By default it is only as wide as its contents and aligned to the left top.
The way you describe it, probably width: 100% would be the adequate value, which stretches the element across the whole width, in which case the text-centering you applied will be effective.

Using width instead br and centering text

Hello, I am trying to style the h1 in two different parts, share your dream and Holiday dream.
I am centering the text using the text-align center in the main tittle class, this center the text in just one line, when I add width 45% to the h1 I achieve having two lines but the text-aligns center stop working.
I don't want to use <br> and I have been told to use width percentages but the problem is it is not center anymore.
Thank you
The text-align still works, it will center the text inside the element.
You change the width of the element, therefor it appears to be off center. So, you'll need to center the element as well. Add margin: 0 auto to the element and it should be working again.
Your text are already aligned in center, it's your div i.e. .main-tittle not aligned center to aligned that center use margin:auto;
.main-tittle{
width:45%; /* try to use pixels px value over-here instead of percentage */
margin:auto;
}

CSS DIV Margin-top

I have a question about margin in CSS. I have a DIV element, which has an image for background. Inside that DIV I have another DIV. I want this DIV inside to be 200px from the top. But, when I do that, the outside DIV also moves down for 200px. Why is that and how to keep the outside DIV on top?
Set padding-top on your outside div.
For an detailed explanation to your problem see here.

vertical aligning floats

How do I vertical align floating elements?
I currently have 3 elements (an image floated left, another image floated right and a div with a margin:0 centered) in a wrapping div. These are currently aligned at the top but I want them to aling at the bottom of the div.
How can this be achieved without using position absolute on them as this is a responsive layout? I have tried making them display:inline-block and vertical-align: bottom but that does not help anything.
In order to use vertical-align on some element, that element must have display:table-cell; css style. http://jsfiddle.net/StPYR/
Your jsfiddle updated: http://jsfiddle.net/chCjT/16/
Instead of floating the elements you need to give them display:inline-block; css property

Force div to scroll if the text overflows HTML/CSS?

So I have a div tag to sort of draw boxes around various sections, and of course make actual sections.
In one of the sections, there is more text than can be held in the div tag, so I want to for the text within the div tag to have a scroll bar to make it so the text doesn't overflow outside of the box.
How would I do that?
Use the following:
div {
overflow: scroll;
}
If you want them to scroll only in one direction, you can use the overflow-x and overflow-y properties.
Add width and height CSS properties to the div, as well as overflow:auto
If you add overlow:scroll, the scroll bars will be always visible.
If you want to have only horizontal scroll, add white-space:nowrap to the element inside of the div.

Resources