I am having trouble making a contenteditable look like a textbox on my site. Does anyone know what is the font on the picture - I have tried a lot of them an none matches well.
The contenteditable is above and the textarea is bellow .. i would like to know what is this font?
Here is the code as well
#mw {
-moz-appearance: textfield-multiline;
padding: 11px;
}
.mw1 {
padding: 11px;
}
<div id="mw" contenteditable>I am not really sure what this font is and I am trying to make a contenteditable area look like a text area.
Thanks for the help.
</div>
<textarea id="aid" name="inputText" class="mw1">I am not really sure what this font is and I am trying to make a contenteditable area look like a text area.
Thanks for the help.</textarea>
Still having trouble with trying to match fonts and color? See this Snippet for details.
SNIPPET
.textBox { font: 400 13px/1.428 'Courier New'; color: rgba(0,0,0,1); }
#textarea {
-moz-appearance: textfield-multiline;
-webkit-appearance: textarea;
padding: 5px;
border-radius: 4px;
border: 2px solid #ddd;
padding: 4;
overflow: hidden; overflow-y: auto;
height: 100px;
background-color: #FFFFFF;
resize: both;
overflow: auto;
width:300px;
height: 100px;
font: inherit;
color: inherit;
}
.maintextarea {
padding: 5px;
border-radius: 4px;
border:solid 2px #ddd;
background-color: #FFFFFF;
width:300px;
height: 100px;
font: inherit;
color:inherit;
}
<section class="textBox">
<div id="textarea" contenteditable>
In this demo, I have wrapped a <section> element around both boxes. It has a class name of .textBox.
This is the CSS:
.textBox {
font: 400 16px/1.428 'Courier New';
color: rgba(57,64,68,1);
}
</div>
<textarea id="firsttextarea" name="inputText" cols="100" rows="20" class="maintextarea">
Now for the 2 editors #textarea and .maintextarea we add the following CSS to both of them:
font: inherit;
color:inherit;
</textarea>
</section>
i think the font is Consolas. but as for making the div appear like a textarea, you can try
<table bgcolor=buttonshadow cellpadding=3 cellspacing=3>
<tr>
<td bgcolor=buttonhighlight>
<div id="mw" style="
font:consolas;
width:400px;
height:200px;
overflow-y:scroll;
overflow-x:hidden;" contenteditable>
I am not really sure what this font is and I am trying to make a contenteditable area look like a text area.
Thanks for the help.
</div>
</td>
</tr>
</table>
Just adjust the Width and or Height to the way you like it.
This would work as long as you don't have a super long string fragment that has no spaces (ie a hyperlink). if you do then that super long word may be cut off.
You can remedy that by changing
overflow-x:hidden;
to
overflow-x:auto;
but that would add a horizontal scroll bar if it is needed. Alternatively you can add a "-" and a space somewhere in the Long word to seperate it into two or more lines
Related
I have a div that s being used as an input box.
<div class="div_input" contentEditable="true" onkeyup="DoThing()" id="an_id_value">455</div>
This is the CSS
.div_input {
background-color: white;
outline:1px solid darkgray;
font: -moz-field;
font: -webkit-small-control;
margin-top: 5px;
padding: 2px 3px;
width: 100px;
}
When you type in the box with characters that are longer than the width the following happens:
On Chrome it acts just like I would like it expands but retains it visual text. On Firefox Quantum it will overrun the other elements to the right.
How can I prevent this behavior? I have tried wrapping it in a fix of fixed width but that does not change anything.
Use word-break: break-all; so all words break when they hit the limit. Something like this:
.div_input {
background-color: white;
outline:1px solid darkgray;
font: -moz-field;
font: -webkit-small-control;
margin-top: 5px;
padding: 2px 3px;
width: 100px;
word-break: break-all;
}
<div class="div_input" contentEditable="true" onkeyup="DoThing()" id="an_id_value">455</div>
Here you have it on JSFiddle: https://jsfiddle.net/c61askwy/1/
Thanks to VXp for pointing out the snippet didn't have the solution hehe
EDIT: I've added the relevant code below at the bottom of this question. As you'll see there, the button is wrapped within a div. Also, this problem only occurs in one browser, that being Firefox, and I'll be using a hack to target that browser only.
I have an input element of type submit (i.e., basically a submit button). The text displayed in this element, as defined in the element's value attribute, appears too low (i.e., too close to the bottom of the button instead of vertically centered). The button has a fixed height.
Naturally, I want to move the button's text, as defined in the value attribute, one or two pixels upwards.
I've tried a few things with the button's padding (top and bottom), but that didn't change anything. [Is that to be expected, BTW?] Therefore, I would like to use relative positioning to move the text upwards a bit.
The thing is, however, that I need to target the text itself, NOT the input/button element. And that's of course because the button itself should stay at its current location, I only want to move the TEXT displayed on the button.
Thus my question: Is there a way, in CSS, to target not the button but only its displayed text (as defined in the value attribute) ?
Of course, other solutions (preferably CSS only) are welcome as well.
Code:
HTML:
<form id="zoekform">
<input type="text" class="" id="search-text" name="search-text" placeholder="Search">
<div class="erom" id="erom2">
<input id="zoekknop" style="float: right" type="submit" method="GET" value="Search!" />
</div>
</form>
CSS:
#zoekform {
height: 29px;
box-sizing: border-box;
margin-top: 6px;
margin-bottom: 9px;
}
.erom {
height: 100%;
display: inline-block;
box-sizing: border-box;
}
#erom2 {
border: solid 1px #452F5D;
width: 27%;
display: inline-block;
box-sizing: border-box;
}
#zoekknop {
float: right;
height: 100%;
color: white;
font-size: 19px;
box-sizing: border-box;
background-color: #446666;
color: white;
letter-spacing: 2px;
border: solid 1px white;
width: 100%;
}
And finally the part where I'm targeting Firefox only, and where I can't get the padding working (and to be sure, the "media query" (it's not really a media query) does work, and in any case I've also tried this without the media query, i.e. as part of the regular CSS):
#-moz-document url-prefix() {
#zoekknop {
padding-top: -1px !important;
padding-bottom: 9px !important; // I set it to 9px for now, so that I could clearly see if it worked
}
}
For some reason form elements are particular and quirky about font.
Assign a font to the <submit>'s parent, then use font: inherit on the <submit> button.
On the <submit> assign line-height of 1.4 to 2 (notice there's no unit like px or em.) I actually have the line-height assigned by inheriting the font from <form> 1.4.
Set width using the ex unit of measurement. One ex is as wide as ax character, making it a great way of gauging how much space you are using in relation to your text. I used 9ex for a 6 character word (i.e. Submit).
This ruleset may help you for Firefox:
input::-moz-focus-inner {
border: 0;
padding: 0;
/* Some users have said these last two are
unnecessary or should be -2px */
margin-top:0;
margin-bottom: 0;
}
Here's some changes I did to your button and search field:
#zoekknop {....
....
border: 2px double white;
line-height: 1.65;
vertical-align: baseline;
}
#search-text {
line-height: 1.75;
vertical-align: baseline;
padding: 4px 3px 0;
}
Review the Snippet below:
#form {
font: 400 16px/1.4'Verdana';
}
#form .sub {
font: inherit;
width: 9ex;
color: blue;
border-radius: 5px;
}
#form .sub:hover {
color: cyan;
background: #888;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#zoekform {
height: 29px;
box-sizing: border-box;
margin-top: 6px;
margin-bottom: 9px;
font: 400 16px/1.4 'Verdana';
}
#zoekform #zoekknop {
color: white;
font-size: 18px;
box-sizing: border-box;
background-color: #446666;
color: white;
border: 2px double white;
line-height: 1.65;
vertical-align: baseline;
}
#search-text {
line-height: 1.75;
vertical-align: baseline;
padding: 4px 3px 0
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
input::-moz-focus-inner {
border: 0;
padding: 0;
margin-top: 0;
margin-bottom: 0;
}
<form id="form" name="form">
<input type="submit" class="sub" value="Submit" />
</form>
<form id="zoekform">
<input type="text" class="" id="search-text" name="search-text" placeholder="Search">
<input id="zoekknop" type="submit" method="GET" value="Search!" />
</form>
This should work
#buttonID{
width: 500px;
height: 500px;
padding-bottom: 100px;//pushes text up inside the button
}
Make sure you define the height, width, line-height, font-size, and padding of the button. Then you should be able to manipulate the padding and line-height to get the result you want. It sounds like the button may be inheriting a line height that is causing the issue.
Targeting the text itself isn't the way to go about this. Would be helpful to see the CSS and HTML of the button, and note which browser the issue appears in.
I would love to style my input field very similar to the divs I am building. However, I am unable to solve sizing issues.
Here is an example
http://codepen.io/anon/pen/kLwlm
And here is one more (with overflow:visible and fixed height)
http://codepen.io/anon/pen/Fxjzf
As you can see, it looks very different than the divs, and no matter what I tried, I could not make them look similar. First of all, I would love to make the input in a way that the text will pop put (overflow: visible? not working).
Secondly, the height should be similar to the divs. Setting the height and line-height properties does seem to effect the temporary text, but when it's clicked (and started to type) it breaks. (check second example)
Shortly, open to suggestions.
Try this solution here:
#import url(http://fonts.googleapis.com/css?family=Playfair+Display:400,700,900,400italic,700italic,900italic);
body {
margin: 100px;
background-color: #f7f7f7;
}
input{
border:0;
}
div, input{
font-family: 'Playfair Display', serif;
font-size: 40px;
background-color: #ff44ff;
width: 100%;
margin-top: 20px;
line-height: 40px;
}
div {
padding: 1px 0px 13px 2px;
color: #999;
}
I tried placing the input in div and then making the input background to transparent. YOu can play with the spacing to you liking, but it works http://codepen.io/anon/pen/Brcpl
I came up with this JSFiddle. I removed the line-height and positioned text using padding instead (that fixed the aligning of the input text).I also styled the placeholder. Here is a part of your CSS which I changed (do read the notes in it).
div, input{
font-family: 'Playfair Display', serif;
font-size: 40px;
background-color: #ff44ff;
width: 100%;
margin-top: 20px;
padding: 5px 0px 5px 0px;/*use padding to adapt the size*/
}
/*Change placeholder properties*/
#s::-webkit-input-placeholder {
color: black;
}
#s:-moz-placeholder { /* Firefox 18- */
color: black;
}
#s::-moz-placeholder { /* Firefox 19+ */
color: black;
}
#s:-ms-input-placeholder {
color: black;
}
PS: I do suggest styling the input-box differently so the visitors of your website notice it is actually a input-box.
What about this one: http://codepen.io/anon/pen/lcgAD
css
div input {
border: none;
font-size: 40px;
width: 100%;
background: transparent;
color: #000;
font-family: 'Playfair Display', serif;
}
div input:hover {
}
div {
color: #000;
background-color: #892;
height: 41px;
}
html
<div>
<input placeholder="Enter E-Mail ayxml#gmail.com" value="Enter E-Mail ayxml#gmail.com"/>
</div>
this is my html
<div class="logoArea">
<img src="images/oifcoman-logo.jpg"/>
<div class="titleClass">Call Center Dashboard</div>
</div>
this is my css
.logoArea {
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
}
.titleClass {
color: #343434;
font-weight: normal;
font-family: 'Ultra', sans-serif;
font-size: 36px;
line-height: 42px;
text-transform: uppercase;
text-shadow: 0 2px white, 0 3px #777;
margin:auto;
background-color:red;
width:40%;
top:10px;
}
This is what the result:
I want it to be this:
Set the image float:left; and the text display:inline-block; and the .logoArea text-align:center;.
Working fiddle
There are few ways to solve this. Here is one with minimal changes to your existing styling.
.logoArea img {
float: left;
}
Usually it requires additional changes in the code for actual centering in the parent window, but it seems to go well with the other styles you already have.
EDIT
Looking again at the result, I'm having second thoughts. My solution is good only for non-dynamic elements (elements that won't change dynamically but remain the same). Since it appears to be a header and therefore a relatively static element, my solution may still be valid, only with adding a required amount of padding-top to the center div. I don't know how much because in your example you used a very large font-size and I have no idea of the size of the image.
You can use CSS vertical-align:middle if the element is td (not div) or try this trick: http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/
Try using:
<div class="logoArea" style="display:table-cell; vertical-align:middle">
<img src="images/oifcoman-logo.jpg"/>
<div class="titleClass">Call Center Dashboard</div>
</div>
Try this:
HTML:
<div class="logoArea">
<img src="http://i.stack.imgur.com/O3d6S.jpg?s=128&g=1"/>
<div class="titleClass">Call Center Dashboard</div>
<div style='clear:both;'></div> </div>
CSS:
.logoArea {
background-color: #f5f5f5;
border: 1px solid #e3e3e3;
border-radius: 4px;
}
.logoArea img {display:block;width:100px;height:100px;float:left;}
.logoArea .titleClass {float:left;}
JavaScript (must include jQuery first)
$(document).ready(function(){
var h=$('.logoArea').height();var ch=$('.logoArea .titleClass').height();
var pTop=((h-ch)/2)+'px';
$('.logoArea .titleClass').css('paddingTop',pTop);
});
Demo: http://jsfiddle.net/zcAjq/
The source code is like this:
<div id="contact">
<div class="form">
<form action="contact.php" method="post" name="contact-us">
<div class="right">
<div class="labeled">
<label for="text">body</label>
</div>
<textarea id="text" name="text" cols="20" rows="5"></textarea>
</div>
</form>
</div>
</div>
And this is css block for textarea and related objects :
div.right {
float: right;
margin: 5px 0;
}
div.labeled {
width: 150px;
float: right;
}
div.right div.form textarea#text, textarea#text {
background: #A2A2A2;
border: 1px solid #811D1D;
height: 50px;
margin-right: 20px;
width: 220px;
color: #FFFFFF;
font-family: Tahoma, Geneva, sans-serif;
font-size: 11px;
}
in FF all things are correct but in IE the textarea hasn't been styled and remains Intact.
You can see difference in below image too :
Also as you can see the label tag styled true in FF and remains intact in IE!
How could I fix these?
Regards...
Not all versions of IE support the textarea styling.
In your code, the textarea is within the div that floats right. Seems like you're asking for odd behaviour. Better float the 'labeled' div (or rather remove that div and do some trickery on the label itself).
http://jsfiddle.net/KzYgt/
overflow: auto; - for the scrollbar
Styling form elements is a serious hell since most of the controls are styled by OS and browser and those styles are hard to override, in some cases impossible. You should however be able to achieve the background color and scrollbar disappearing.
Are you certain there is no other element with the id "text" on your page?
A good overview of what's possible with css for textarea styling can be found here: http://www.456bereastreet.com/lab/styling-form-controls-revisited/text-input-multiple/#ie6-xp
Solved!
There was just this css block on page's header :
div.form input[type="submit] {
padding: 2px;
background: #A2A2A2;
border: 1px solid #811D1D;
color: #000000;
height: 20px;
}
And As you see there is one lost quotation mark at [type="submit"]. IE couldn't correct code but other browsers do that! This was the problem
P.s: Special thanks to #Bakudan for introducing jsfiddle Online Editor
Regards...