I found this great example: http://codepen.io/tacrossman/pen/GJglH
<div class="animation">
<span class="type">beaches<span>_</span></span>
<span class="type">color<span>_</span></span>
<span class="type">happiness and blah blah<span>_</span></span>
<span class="type">wonder<span>_</span></span>
<span class="type">sugar<span>_</span></span>
<span class="type">sunshine<span>_</span></span>
</div>
The problem is for the third span, I added 'and blah blah' to the end of the line. As you can see, the text now bunches up and doesn't follow the same transition effect as the others. I've tried adjusting the values but then the other four spans are screwed up. Any ideas?
Make sure the text doesn't wrap using this additional CSS:
.type{
white-space: nowrap;
}
or
.type{
white-space: pre;
}
Updated CodePen - Better than editing the text (in my opinion):
Adding non-breaking spaces between the words fixes the issue:
<div class="animation">
<span class="type">beaches<span>_</span></span>
<span class="type">color<span>_</span></span>
<span class="type">happiness and blah blah<span>_</span></span>
<span class="type">wonder<span>_</span></span>
<span class="type">sugar<span>_</span></span>
<span class="type">sunshine<span>_</span></span>
</div>
New version here: http://codepen.io/anon/pen/Jtlnk
use
<span class="type">happiness and blah blah<span>_</span></span>
Related
Expected behavior: long line of text wraps to next line.
Actual behavior: Long line of text does not wrap and instead automatically goes to next line with no wrapping.
Current HTML:
<p style="" class="subject">
<span data-l10n-id="message-subject">Subject:</span>
<span style="" class="detail">Re:jkla;sjdfkjasdf;jkasd;flkjasdf;kljasdf</span>
</p>
The span with the class detail has the css style word-wrap:break-word.
You need to give some space between the word. Other wise it is counted as whole word.
<p style="" class="subject">
<span data-l10n-id="message-subject">Subject:</span>
<span style="" class="detail">Re: jkla; sjdfkjasdf; jkasd; flkjasdf; kljasdf</span>
</p>
span{
word-break: break-all;
}
Working Fiddle
I have below line which is causing next line after text 100% and 99.8%
can anyone pls help me how can i display all this in one line side by side.
<span style="font-size:12px;font-weight:bold;padding-left:800px;">99%>=<span style="color:#69BB1D;">GREEN</span><=100%, <span style="padding-left: 950px;">41%><span style="color:#FFD700;">YELLOW</span><99.8%,</span> <span style="color:#EE543D;padding-left:1100px;">RED</span><99.6%</span><br />
I believe the issue is "padding-left" in each span, it causes them to go to next line because they can't fit to the screen.
If you remove the padding -or at least decrease the value- they will be showing in one line side by side.
Example Here:
https://jsfiddle.net/zjbot272/
<span style="font-size:12px;font-weight:bold;">99%>=
<span style="color:#69BB1D;">GREEN</span><=100%,
<span style="">41%>
<span style="color:#FFD700;">YELLOW</span><99.8%,</span>
<span style="color:#EE543D;">RED</span><99.6%</span>
Try adding white-space: nowrap;. Anyway what you are doing is weird.
<span style="font-size: 12px; font-weight: bold; padding-left: 800px; white-space: nowrap;">99%>=<span style="color:#69BB1D;">GREEN</span><=100%, <span style="padding-left: 950px;">41%><span style="color:#FFD700;">YELLOW</span><99.8%,</span> <span style="color:#EE543D;padding-left:1100px;">RED</span><99.6%</span>
I want to add an iframe to the right of the vertical-alignment
http://s13.postimg.org/s5f54mux3/Screen_Shot_2015_07_30_at_4_45_06_PM.png
The code to it is:
<div style='margin-left:10px;'>
<img src='/' class='circular' style='float:left;vertical-align:middle;'>
</div>
</span>
<span class='txt'>
<span class='user-info'>
Text
</span>
<br>
<span class='user-time'>
12 Minutes Ago
</span>
</span>
</span>
</span>
</div>
How do you add an iframe to float on the right of the vertical-alignment, like so...
http://s30.postimg.org/5qfa3x8o1/Screen_Shot_2015_07_30_at_4_45_06_PM.png
I think the best solution would be to add a float:right and position it as the last element of the span that contains the user information.
I think I placed it correctly below but the code you posted is missing the top half, making it kind of difficult to guess what is what..
<div style='margin-left:10px;'>
<img src='/' class='circular' style='float:left;vertical-align:middle;'>
</div>
</span>
<span class='txt'>
<span class='user-info'>
Text
</span>
<br>
<span class='user-time'>
12 Minutes Ago
</span>
</span>
<iframe style:'float:right;'></iframe>
</span>
</span>
</div>
To put an element on the right, you can either use float: right or absolute positioning. Personally I would use absolute positioning. Here is a solution:
#theIframe {
position: absolute;
top: 0;
right: 0;
}
Also make sure the containing element is position: relative (or any other position except the default "static".)
I'm reluctant to butt in where a solution seems to have been reached but I'm wondering why one wouldn't use Flexbox. I understand that it's not supported in IE9- but the data at Can I Use suggests that this is a negligible concern and that cross-browser support is wide. Can I Use Flexbox (Note: review both the "Current Aligned" and "Useage Relative" data.)
With that in mind, would you consider something along the lines of the following.
//HTML
<div style='margin-left:10px;'>
<img src='/' class='circular' style='float:left;vertical-align:middle;'>
</div>
</span>
<div id="Flex-Container">
<span class='txt'>
<span class='user-info'>
Text
</span>
<br>
<span class='user-time'>
12 Minutes Ago
</span>
</span>
<div id="Responsive-Iframe-Container">...</div>
</div>
</span>
</span>
</div>
//CSS
#Flex-Container {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
}
#Responsive-Iframe-Container {
width: 45%;
}
The HTML and CSS for the markup inside #Responsive-Iframe-Container can be found in the Pen Responsive Iframe - Flexbox.
Of course, instead of using #Responsive-Iframe-Container, one could simply substitute <iframe src="#"></iframe> styled as desired.
I am a beginner autodidact in HTML and CSS, so if there is something wrong with the suggested code, please forgive me and please let me know what it is.
I want to create a clickable rounded rectangle that will change color when clicked, using bootstrap. The best way I found to do this is with a span.
Here is the example code I've written:
<p id="proyect_c_leasons" style="height:30px;vertical-align:middle;display:table-cell"> <span class="label label-default" style="background-color:#D80909;width:35px;height:25px;display:inline-block" onclick='console.log("hola")'> </span> <b>Lecciones Aprendidas</b> </p>
This is what it shows:
What I want is the text to be align to the middle of the red square instead of the bottom of the red square.
This code:
<p id="proyect_c_leasons"> <span class="label label-default" style="background-color:#D80909;width:35px;height:25px;display:inline-block" onclick='console.log("hola")'> </span> <b>Lecciones Aprendidas</b> </p>
Shows the exact same thing (basically p ignores everything I write into style)
Can anyone provide me with a way to fix this? Or an alternative?
Set line-height for the div and then vertical-align the span within.
<p id="proyect_c_leasons" style="height:30px;line-height:30px;display:table-cell">
<span class="label label-default" style="background-color:#D80909;width:35px;height:30px;display:inline-block;vertical-align:middle;" onclick='console.log("hola")'>
</span>
<b>Lecciones Aprendidas</b>
</p>
Bootply
Try giving the vertical-align: middle; and line-height equal to the height to the <span>:
<p id="proyect_c_leasons">
<span class="label label-default" style="background-color:#D80909;width:35px;height:25px;line-height:25px;display:inline-block;vertical-align: middle;" onclick='console.log("hola")'></span>
<b>Lecciones Aprendidas</b>
</p>
<p id="proyect_c_leasons" style="line-height: 25px;"> <span class="label label-default" style="background-color:#D80909;width:35px;height:25px;display:inline-block; float: left;" onclick='console.log("hola")'> </span> <b>Lecciones Aprendidas</b> </p>
It was somewhat unclear what you were asking here, so I'll answer both interpretations.
a) You want the text in the middle of the square (contained within)
This is a relatively simple change. You just need to contain the text within the span.
b) You want the text to be vertically in the middle of the square (still outside of it)
For this, you'll want to look at text alignment.
<p id="proyect_c_leasons" style="height:30px;vertical-align:middle;display:table-cell">
<span class="label label-default" style="background-color:#D80909;width:35px;height:25px;display:inline-block" onclick='console.log("hola")'>
</span>
<b style="vertical-align: 40%;">Lecciones Aprendidas</b>
In the example above I've literally only changed the style for the <b> tag. You can alter where it lies by changing the percentage. There are a variety of different options available to you, which are listed on mdn:
https://developer.mozilla.org/en/docs/Web/CSS/vertical-align
I have a contenteditable text structure like so:
<div class="content" contenteditable="true">
<span contenteditable="false">
<span class="chunk" contenteditable="true">This sentence contains </span>
</span>
<span contenteditable="false">
<span class="chunk bold" contenteditable="true">some bold</span>
</span>
<span contenteditable="false">
<span class="chunk" contenteditable="true">text!</span>
</span>
</div>
This enables selecting text across all 3 "chunk" spans. However, removing the "outline" from it using css disables selecting text:
.chunk {
outline: 0px solid transparent;
}
Can anybody explain why? JSBIN example
EDIT
It's definitely the EXISTENCE of the outline that's causing the issue. Giving it a 1px solid transparent outline still allows text selection. As soon as you specify 0px, it prevents selection.