Many sites show suggestions for what you are typing as a drop down, with some showing the most likely result as a "preview" to the right of the cursor in a lighter-gradient font.
For example (this is from Spotlight on my Mac):
spotlight text suggestion
Is there any way to reproduce this within a standard HTML input element, or does it require a more complicated rich text (e.g. Slate) approach?
Unfortunately, this is not possible via the input tag.
However, there are a couple of ways to do that.
Slate is a option but I think you can craft something way easier.
For example, you can make a <div> with the attribute contenteditable. When you type, the div expands and after the "input div" you put another element which has the autocompleted results.
Either way you definitely need JS to accomplish that. Wor splicing the String or for going through your possible results. If you still have this problem, I could write a smapp codepen demo.
Related
I am looking at this website here, https://www.symbolab.com/
, and in particular the matrix entry function on it. Pressing the icon with the brackets to the left of the H2O icon will take you to it.
Now, you are then prompted to enter your own user-defined size of matrix. Below then in a text area then appears the blank matrix, with the predefined text fields arranged in an array.
I am wanting to replicate something similar myself, and was wondering how this site was performing this function. I am new to HTML and was wondering what components were being used here? Is the larger area that the matrix is contained in a canvas? Are the fields of the matrix Input Type Text fields? If so, how is the resizing dynamically achieved as the user enters text?
Anyone know? :)
Jeremy
The first step when you want to know what's happening behind a website is to open the console and look at the code and scripts. I think that the textarea used into your example is a basic textarea.
If your looking for a textarea that auto-resize, you can achieve this in JS. Maybe that post can help you.
If your looking for a way to write math formula into an HTML page, there is several solutions for you on the web. That stackoverflow post propose to use MathJax.
Hope it helps you a bit.
I have a couple of questions about the problem of hiding text inside an anchor tag and only displaying a background image.
Note to those about to bombard me with links to other articles and tell me that this is a repeat question: I have scoured this site and the web in general and read the solutions (and by solutions I mean mostly hacks) people came up with. What most people seem to be doing (or have done up until recently) was the -9999px hack. Also popular is/was wrapping the text in a span and doing something like this or visibility: hidden.
Now, I personally think that "hiding" the text would really only make sense in the first place if it was hidden dynamically, i.e. displayed only if the background image wasn't loading (for whatever reason). However, all the "solutions" I found effectively remove the text completely or at least hide it permanently so even if the background image isn't loaded, the text still wouldn't be displayed.
So here are my questions:
Why would one want to have text and then permanently hide it at all? Why not just leave the anchor empty - i.e. just don't put any text in it - and only have the image displayed? Why have text and then go through the headache of figuring out how to hide it? What's the point of that? Am I missing something here?
Now that we have CSS3, are there actual non-hacky, dynamic ways to hide text when the background image is displayed and have the text appear when the image - for whatever reason - fails to load? I couldn't find any resources so I am assuming this is not supported but maybe one of you ninjas knows better?
There are different possibilities why to do that:
Search Engines scan the web and also gather content that is visually hidden. The site gets better in terms of semantics and has a higher page rank.
Many visually impaired people rely on content that's read to them by screenreaders. Sometimes text in the alt-tag is just not enough. Background images don't even have such a tag.
To your second question:
To me there is no known way to check if a background-image is successfully loaded and is also shown (a totally different story!). CSS only styles content according to defined rules. There may be a javascript way to do it, but in my opinion it isn't worth the cost because mostly this text isn't really a fallback. It has a different purpose as stated above.
First post here, looking for suggestions how I might achieve something.
I have a few symbol fonts I've designed that I would like to display online.
I'd like a type testing area where you use the font.
I think I might be able to do this with php and the GD library - Type something
into a text box then use php to create and image.
What I'd really like is something like this.
http://www.mckltype.com/retail/
You can type straight into the text and it's displayed live.
I thought this might be done with an input text field but the code for this page just has a div.
Any ideas on how I might achieve something like this.
I'm not looking to copy this just ideas on how I can type on a page in a font.
If you look at that page source, you'll see that those elements have contenteditable="true", which makes them editable.
You could also just make an <input type="text" /> and use CSS to change the font and hide the border.
When you touch an element, such as an edit box, in a web page on the iPad, it turns gray while you are touching it.
I have a table wrapped by a floating div. Instead of an individual data element or row going gray, the whole table (or its wrapping div) goes gray when a data element is touched. (The function of this table is an autocomplete pop-up)
Elsewhere in the site, I have a table in which only the touched data element goes gray.
I wondered if anyone could direct me to an explanation of the logic behind this graying on touch, so that we can code our table to give the desired behavior. Ideally, we'd like the row to highlight when it is touched.
In the alternative, if we could turn off this graying behaviour, that would be another option. We could then code the highlighting ourselves. Is there a way to turn off this behavior for particular html elements?
Thanks.
This author suggests a solution to remove the highlighting:
If for whatever reason you don't want some elements of your web site or application to be highlighted, simply add the following CSS rule to the corresponding elements.
-webkit-tap-highlight-color: rgba(0,0,0,0);
It won't disable the highlighting, but it will make it invisible (an opacity of zero).
I have not tested this, however.
I have discovered something about the "logic" behind the graying behavior. It seems that elements that have handlers such as onclick, onmousedown etc. exhibit the behavior and those without such handlers don't. A (somewhat tedious) workaround for us is to change the code of the autocomplete so that each row has its own onmousedown etc. handler rather than the wrapping div taking care of this.
Try styling the wrapper div with select:none;
That should turn it off, and then you could code the highlight onfocus yourself.
Most browsers actually do this, but it's a bit more noticeable on the iPad and other Apple touch products. It's really for usability purposes, so I would only recommend disabling it if it is causing problems like the one you mentioned. It serves to help the user know what they are clicking, and gives them a chance to move their finger away if they are on the wrong thing.
The discussion on this answer to the question "How can I use Google's new imageless button?" Has prompted this question.
Google seems to think that going imageless is good for some reason, but from the comments cited, I fail to see the advantage. Is it worth it to send dozens of lines of HTML and who knows how much CSS to render these imageless buttons, rather than simply load another image, especially when techniques like CSS sprites are available?
When would this technique be preferred? The other question asks how it can be done, but I want to know why it should be done.
Localization (it's easier to translate text than images)
Skinning/themeing (it's easier to change the look and feel with single CSS than recreate multiple images)
Accessibility (screen readers can read properly, text scaling works properly)
Performance (the CSS is shared and so is loaded once from the server)
Functionality (it's easier to expand the button with new UX elements like dropdown arrow when you don't have to change the whole picture)
Btw, the "imageless" button might as well contain an image inside the visual template. This approach is quite similar to XAML's approach to templating and styling the visual tree.
I think in this specific case I can only see the advantage that the buttons can be programatically generated. If you don't know what your button will say it's probably easy to make this way than generating it using somekind of image library generator.
Also changing one CSS can make you change the look-and-feel of all buttons at once. Using image buttons you'll need to update everyone and each of images.
Isn't this done because the height of the button may vary (for example the text size)?
The page load is smoother as no images have to be loaded and will appear later than the rest
The button text is also readable in the case somebody cannot read/view images, yet you have the graphical look. (building a graphical button with images in the traditional way around real text is as complicated HTML as this method)
As they mentioned in their blog, these buttons are skinnable without creating and storing custom images.
Basically, you get all the advantages of plain text buttons over custom imaging, while still having a nice, skinnable graphical look.