How to fix the height of the vertical text? It is not working properly with line-height or height property
Here is my demo
http://jsfiddle.net/BsZ8f/1/
I tried my hand on the code but couldn't figure out. My solution would be to use just css2 to create vertical text, for this you just need to give the .title a fixed width say 10px just enough to hold one character, this way the text will automatically get aligned vertically and give height: auto; overflow: auto; to make sure the height adjusts.
Related
Well i know about overflow-y: hidden, but I dont like that my site "jumps" to the right side like for 20px every time i use overflow-y: hidden.
Is it possoble to block scrolling without "jumping"?
here is example http://jsfiddle.net/wjyb8tzw/6/
Just give a margin or padding of 20px at the right side.
padding-right:20px;
The line overflow-y disables the scrollbar on the right, this changes the maximum width of the webpage.
The line margin: auto centers the div based on the maximum width of the webpage, therefore disabling the scrollbar moves the div a little to keep it centered.
If you specifically don't want the div to be centered then use margin-left: -17px; as the width of the of the scrollbar is 17 pixels as stated here.
Flexbox can be used to vertically align elements. But when a vertically-aligned element later grows, it can escape the bounds of its flexbox container. This happens even when overflow:auto is used on the element.
Here's a demo with some expected and actual results.
Using the demo:
Open the demo
Enter lots of text in the gray box
Expected result:
The paragraph becomes taller as text is entered. When the paragraph is as tall as its flexbox container, it stops growing and a vertical scrollbar is shown.
Actual result:
The paragraph becomes taller as text is entered, but never stops growing. It ultimately escapes the bounds of its flexbox container. A scrollbar is never shown.
Other notes:
It's tempting to put overflow:auto on the container instead, but that doesn't work as expected. Try it out. Enter lots of text and then scroll up. Notice that the top padding is gone and lines of text are missing.
You need to do the following:
Add "max-height: 100%" on the <p> element to keep it from growing indefinitely.
If you want to keep your padding on the <p>, you also need to set box-sizing: border-box to get its padding included in that max-height.
(Technically box-sizing:padding-box is what you want, but Chrome doesn't support that; so, border-box will do, because it's the same as the padding-box since there's no border.)
Here's your JS Fiddle with this fix
In your css you need to give height
p {
padding: 20px;
width: 100%;
background-color: #ccc;
outline: none;
height: 60px;
}
JS Fiddle
I have navigation points with text in it (longer and shorter). The text should be centered, but the text itself is aligned left; complicated to explain. Please have a look at my picture:
The upper three are my is-state but the lower three the should-be-state.
With display: inline my elements have the correct size (even with word breaks). So I gave the parent text-align: center to center the text-container horizontally. But: the text within the container should have text-align: left. But with display: inline this is not possible.
BTW: display: inline-block is not a solution because it strechs the container with longer text to 100% width even if the broken text does not fit.
See here: http://jsfiddle.net/z5jo64bj/
Is there a way without JavaScript to solve this?
I have a problem with content from a div, for example if I put a table inside of a div and set a width (width:200px !important)for that div the table it will overwrite that div. So how is possible to keep all content inside that div?
fiddle example:
http://jsfiddle.net/ebG9N/45/
You set the header to white-space: nowrap; therefore, the browser is unable to break the headers, so the width of the table will be bigger than the container div.
You can set, overflow: hidden; to cut the overflowing parts, or overflow: auto; to create a scrollbar, but without them it's the correct rendering.
There are two solutions.
i) IF you want to STRICTLY contain table WITHIN div then overflow:auto; is the way to go.
ii) BUT if you change your mind and want to WRAP div to the width of table then.
display:table; is the way to go.
Generally its bad idea to contain wider element within explicitly known less wider element.
Try using overflow:auto; in the css of the div.
You can't just expect it to somehow fit within a div of any size you wish. What you can do is, at least allow the browser to scroll (overflow: scroll) it using:
div.divano{
width:200px !important;
border:2px solid yellow;
background:#eaeaea;
height:200px;
overflow: scroll;
}
You may also use oveflow: hidden, but it would just hide the parts that are not visible. Also, overflow: scroll, will always show a scroll bar (with or without clipping). You can use overflow: auto to specify that the content should be scrolled only if clipping occurs.
I want to set a background image in a div class, and want to add some text on the image, with 5px padding but my text is overflowing, please see my css and demo here http://jsfiddle.net/LcQzG/ and help me with it. Thanks.
You should set a width and add
word-wrap:break-word;
example : http://jsfiddle.net/LcQzG/6/
Either make the background image higher, make the text smaller, make the box wider or add this to add a scroll bar:
overflow: auto;
or to hide the overflowing text:
overflow: hidden;
You need to set a width on the containing div. The width would be the width of the image - 10px (the sum of the left and right padding).