how do you create tags like stackoverflow with text styling

╄→гoц情女王★ 提交于 2020-01-01 12:23:27

问题


I was wondering how you can create css styling inside an input field such as stackoverflow's tagging system?

When you click on a tag, the text will be styled. And also, when you click on the styled tag, it will be normal again. I guess my main concern is how to style text inside an input field?

Thanks!


回答1:


This might help you: http://basdebie.com/jquery-plugins/jquery-tags-autosuggest-like-delicious-stackoverflow-facebook/

By looking at this code, you should be able to create something similar, or just use the plugin.




回答2:


The tags are not input fields, they are links! On SO, the tags use the following styles:

.post-tag {
    color: #3E6D8E;
    background-color: #E0EAF1;
    border-bottom: 1px solid #3E6D8E;
    border-right: 1px solid #7F9FB6;
    padding: 3px 4px 3px 4px;
    margin: 2px 2px 2px 0;
    text-decoration: none;
    font-size: 90%;
    line-height: 2.4;
    white-space: nowrap;
}

a.post-tag:hover {
    background-color: #3E6D8E;
    color: #E0EAF1;
    border-bottom: 1px solid #37607D;
    border-right: 1px solid #37607D;
    text-decoration: none;
}



回答3:


Only the bit you type in is an input, the other tags are just styled a elements. When you hit return, the input moves right and gets shorter, and the value is copied and a new a element is created.

The text in the input isn't styled.



来源:https://stackoverflow.com/questions/7960522/how-do-you-create-tags-like-stackoverflow-with-text-styling

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!