placeholder

How can I implement Stack Overflow-like watermarks in forms?

∥☆過路亽.° 提交于 2019-11-28 23:42:31
问题 I remember seeing a tutorial somewhere that talks of how to style your input forms in a more “usable” way. Essentially, you have a placeholder value and when you enter the input, it hides the hint so to speak. Now, just to be clear: I don't want the hint (placeholder value text) to disappear on focus, but rather to go lighter when I first start typing something. Good examples: Check out the forms on Aardvark. This is exactly how I wish to have my input forms. Our very own Stack Overflow —

How to set an input width to match the placeholder text width

拈花ヽ惹草 提交于 2019-11-28 22:28:50
Example http://dabblet.com/gist/5859946 If you have a long placeholder, the input by default does not display wide enough to show all the placeholder text. e.g. <input placeholder="Please enter your name, address and shoe size"> Without setting a fixed width, and preferably no javascript, can you set the input to show all the placeholder text? This can be done only via javascript by setting the size = placeholder length: input.setAttribute('size',input.getAttribute('placeholder').length); Here is a code that dose that for all the inputs: http://jsfiddle.net/KU5kN/ Just in case someone wants to

配置文件或模板中的占位符替换工具类

笑着哭i 提交于 2019-11-28 21:46:30
import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * 配置文件或模板中的占位符替换工具类 */ public class PlaceholderUtils { private static final Logger logger = LoggerFactory.getLogger(PlaceholderUtils.class); /** * 占位前缀: "${" */ public static final String PLACEHOLDER_PREFIX = "${"; /** * 占位后缀: "}" */ public static final String PLACEHOLDER_SUFFIX = "}"; public static String resolvePlaceholders(String text, Map<String, String> parameter) { if (parameter == null || parameter.isEmpty()) { return text; } StringBuffer buf = new StringBuffer(text); int startIndex = buf.indexOf

How to deal with “%1” in the argument of QString::arg()?

天大地大妈咪最大 提交于 2019-11-28 21:18:49
Everybody loves QString("Put something here %1 and here %2") .arg(replacement1) .arg(replacement2); but things get itchy as soon as you have the faintest chance that replacement1 actually contains %1 or even %2 anywhere. Then, the second QString::arg() will replace only the re-introduced %1 or both %2 occurrences. Anyway, you won't get the literal "%1" that you probably intended. Is there any standard trick to overcome this? If you need an example to play with, take this #include <QCoreApplication> #include <QDebug> int main() { qDebug() << QString("%1-%2").arg("%1").arg("foo"); return 0; }

JS实现HTML5属性placeholder效果

南楼画角 提交于 2019-11-28 17:22:13
placeholder属于HTML5新增的一个属性,但是因为存在兼容问题,所以可以用JS来实现它的功能 思路:使用到两个事件:onfocus和onblur,当输入获得焦点时,判断输入的内容,使其为空。当输入框失去焦点时,判断输入框是否为空,如果为空的话,value值变回原来默认的值 <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <title>Document</title> <style> input { width: 200px; height: 24px; line-height: 24px; border: 1px solid #999; background: #FFF; margin: 15px 0 0 100px; padding: 4px; color: #CCC; } </style> </head> <body> <input type="text" value="请输入姓名" id="txt1"> <br> <input

How to test if the browser supports the native placeholder attribute?

天涯浪子 提交于 2019-11-28 17:11:05
I'm trying to write a simple placeholder jQuery plugin for a site of mine but of course I only want to fire the function if the native placeholder attribute isn't supported… How can I use jQuery to test for native support of the placeholder attribute? lonesomeday You can add to $.support quite easily by inserting this at the top of the Javascript you've written: jQuery.support.placeholder = (function(){ var i = document.createElement('input'); return 'placeholder' in i; })(); You can then use either $.support.placeholder or jQuery.support.placeholder anywhere in your code. NB This code adapted

How to create WPF usercontrol which contains placeholders for later usage

。_饼干妹妹 提交于 2019-11-28 16:51:08
I'd better ask the question by example. Let's say I have UserControl and Window which uses this control. I would like to design this control (named MyControl) in such way (this is sci-fi syntax!): <Grid> <Button>Just a button</Button> <PlaceHolder Name="place_holder/> </Grid> and use in such ways when designing my Window: <MyControl/> or <MyControl> <place_holder> <Button>Button 1</Button> </place_holder> </MyControl> or <MyControl> <place_holder> <Button>Button 1</Button> <Button>Button 2</Button> </place_holder> </MyControl> Of course I would like to have ability to add even more elements to

UISearchBar change placeholder color

瘦欲@ 提交于 2019-11-28 16:26:03
问题 Has anyone any idea or code sample on how can I change the text color of the placeholder text of a UISearchBar? 回答1: for iOS5+ use the appearance proxy [[UILabel appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor redColor]]; 回答2: Found the answer from Change UITextField's placeholder text color programmatically // Get the instance of the UITextField of the search bar UITextField *searchField = [searchBar valueForKey:@"_searchField"]; // Change search bar text color

Tensorflow define · Dyting's Blog

故事扮演 提交于 2019-11-28 16:19:35
Tensorflow 概念 Tensor Tensor是TensorFlow中主要的数据结构,是一个多维数组。例如可以讲一小组图像集表示成一个四维的浮点数数组,这四个维度分别是[batch,height,width,channels]. 创建tensor有两种方式,一是直接用tensorflow自带的函数创建,二是用Python的numpy库创建。 第一种如下: 12 import tensorflow as tftf.zeros([row_dim,col_dim]) 第二种方式: 123 import numpy as npx_data=np.array([[1,2,3],[4,5,6]])tf.convert_to_tensor(x_data,dtype=tf.float32) graph图 一个完整的TF代码主要分成2个部分,定义(构建)和执行。通常在构建阶段创建一个图表示和训练神经网络。 如下图所示: Tensor在一个或者多个由节点和边组成的图中流动,边代表tensors,节点代表对tensors的操作。 如图,节点a接收了一个1-D tensor,该tensor从节点a流出后,分别流向节点b和c。。 一旦开始一个任务,一个默认的图已经创建好了,可以通过调用tf.get_default_graph)()来访问。在默认的图里面添加操作,如下例子所示: 12345