Make text invisible in contenteditable - html

I have a contenteditable span (display set to inline-block, so it doesn't act like a span, per se). I want the span to act like a password field on a linux terminal; you're typing, but you can't actually see it.
I've tried visibility: hidden and display: none, but both break the formatting and the text is still visible. Setting the color to the same as the background (black) makes the text invisible, but the caret is too.
I'd prefer for this to be done with CSS, but if it can't be done, I'll just use JavaScript. Here's my code:
.input {
display: inline;
}
body {
background-color: black;
}
#field-in {
color: #ffffff;
outline: none;
display: inline-block;
}
<div class="input">
<span id="field"><span id="field-name">Invisible Text:</span><span id="field-in" contenteditable> </span></span>
</div>

You can change the caret color so that the caret is shown:
.input {
display: inline;
}
body {
background-color: black;
color: white;
}
#field-in {
color: #000000;
caret-color: #ffffff;
outline: none;
display: inline-block;
}
#field-in::selection, #field-in::-moz-selection {
color: #000000;
background-color: #000000;
}
<div class="input">
<span id="field"><span id="field-name">Invisible Text:</span><span id="field-in" contenteditable> </span></span>
</div>

Two CSS properties:
color: rgba(0,0,0,0);
caret-color: red;
One CSS pseudo-element:
::-moz-selection { background: rgba(0, 0, 0, 0); }
::selection { background: rgba(0, 0, 0, 0); }
The caret needs a contrasting color so adjust accordingly with caret-color. The value rgba(0,0,0,0) is transparent black -- the fourth 0 is alpha (opacity). The selection highlight is the same color so if the user selects the text with the default color (blue in Chrome) the text would be not be revealed. Note, this will work with any color background.
.input {
display: inline-block;
}
body {
background-color: none;
}
#field-in {
outline: none;
color: rgba(0, 0, 0, 0);
caret-color: red;
display: inline-block;
}
#field-in::-moz-selection {
background: rgba(0, 0, 0, 0);
}
#field-in::selection {
background: rgba(0, 0, 0, 0);
}
<div class="input">
<span id="field"><span id="field-name">Invisible Text:</span><span id="field-in" contenteditable>Test</span></span>
</div>

Related

white text stand out in the grey background

I have a div tag with background-color: #FFFFFF and opacity: 0.08. Inside it is a span tag with the colour white. What can I do to make the white text stand out in the grey background in the parent div? It seems that i cannot increase parent's opacity
Or you should be able to get this effect by using rgba() notation:
div{
background-color: rgba(255, 255, 255, 0.08);
}
span {
color: #fff;
}
Just make it a fairly dark grey:
#background {
background-color: #222222;
text-align: center;
vertical-align: middle;
}
#text {
color: #FFFFFF;
background-color: #444444;
}
body {
font-family: sans-serif;
}
<div id="background" style="height: 100vh; width: 100vw;">
<span id="text">Ngay Nhap Vien</span>
</div>
You could use text-shadow as well along with RGBA Fiddle
HTML:
<div>
<span>text</span>
</div>
CSS:
div {
background-color: rgba(255, 255, 255, 0.08);
}
span {
color: #FFF;
text-shadow: 0px 1px 10px black;
font-size: 30px;
}

Is it possible to preserve toggles in Inline CSS or do some other trick to send collapsible sections in emails?

I have little experience in HTML so I apologize if this question has already been answered.
I want to send an email that has a few very long sections so I want them to be collapsible. I don't know much html/css but I was able to put something together that collapses the sections. However, whenever I convert it to inline css, I can no longer view the sections that are displayed.
I am open to other ideas on collapseable sections, however, I cannot use regular css, anything that falls under , any javascript, and anything in external documents.
Sample code below
<head>
<style>
body {
font-family: "Open Sans", Arial;
background: #CCC;
}
main {
background: #EEE;
width: auto;
margin: 20px auto;
padding: 10px 0;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
h2 {
text-align: center;
}
p {
font-size: 16px;
}
input {
display: none;
visibility: hidden;
}
label {
display: block;
padding: 0.5em;
text-align: center;
border-bottom: 1px solid #CCC;
color: #444;
}
label:hover {
color: #000;
}
label::before {
font-family: Consolas, monaco, monospace;
font-weight: bold;
font-size: 15px;
content: "+";
vertical-align: text-top;
display: inline-block;
width: 20px;
height: 20px;
margin-right: 3px;
background: radial-gradient(ellipse at center, #CCC 50%, transparent 50%);
}
#expand0 {
height: 0px;
overflow: hidden;
transition: height 0.5s;
background: #FFF;
color: #000;
}
section {
padding: 0 20px;
}
#toggle0:checked~#expand0 {
height: 85px;
}
#toggle0:checked~label::before {
content: "-";
}
</style>
</head>
<main>
<input id="toggle0" type="checkbox" checked>
<label for="toggle0">Example</label>
<div id="expand0">
<section>
<p>Hello There</p>
<p>General Kenobi</p>
</section>
</div>
</main>
Inline of Example
<main style="background-color:#EEE;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;width:auto;margin-top:20px;margin-bottom:20px;margin-right:auto;margin-left:auto;padding-top:10px;padding-bottom:10px;padding-right:0;padding-left:0;box-shadow:0 3px 5px rgba(0, 0, 0, 0.3);" >
<input id="toggle0" type="checkbox" checked style="display:none;visibility:hidden;" >
<label for="toggle0" style="display:block;padding-top:0.5em;padding-bottom:0.5em;padding-right:0.5em;padding-left:0.5em;text-align:center;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#CCC;color:#444;" >Example</label>
<div id="expand0" style="height:0px;overflow:hidden;transition:height 0.5s;background-color:#FFF;background-image:none;background-repeat:repeat;background-position:top left;background-attachment:scroll;color:#000;" >
<section style="padding-top:0;padding-bottom:0;padding-right:20px;padding-left:20px;" >
<p style="font-size:16px;" >Hello There</p>
<p style="font-size:16px;" >General Kenobi</p>
</section>
</div>
</main>
Your example doesn't work because you can't specify inline styles for checked status.
You have to use css for that.
On another note: You say that you want to use this in an email, I don't think any email client would render your collapsible content.
So to answer your question: You have to use CSS (file or tag) for this type of behaviour, it's not possible with inline CSS alone. If you want to send this via email it would be better to dismiss these collapsible elements altogether and maybe reduce the amount of stuff you send out in an email.

Customizing css file to display icon

I've been trying to customise an icon to show a logo in my header, but I don't know how to set up correctly my css file for this. I'm using Bootstrap, and the logo is stored in my static folder: /static/img/logo.jpg
First of, my code loads the bootstrap css file first, then my custom css file.
Then my html file references this:
...
<div class="page-header" >
<div class="container">
<h1><i class="icon-logo"></i></h1>
...
My css file so far contains this:
...
.page-header {
height: 60px;
margin-top: 0px;
background: red;
color: black;
font-size: 15px;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
z-index: 11;
}
.container {
width: 100;
height: 100;
}
.container h1 {
display: inline-block;
position: relative;
top: 0;
color: white;
font-size: 20px;
line-height: 20px;
font-weight: normal;
}
a {
position: center;
color: white;
text-decoration: none;
}
a:hover {
color: white;
text-decoration: underline;
}
...
What should I add to the css file to customise and display the logo?
I don't understand what exactly you wan't to do.
If you want the style the icon, just apply your CSS to that : .page-header .container h1 a i
But I think you wan't to replace the icon, so if you wan't to display your logo, and then style it, you could set your html like that :
<div class="page-header" >
<div class="container">
<h1><a href="https://mywebsite.com"><img src="/static/img/logo.jpg" alt"logo">
</a></h1>
</div>
</div>
And then apply your style to .page-header .container h1 a img
And it should be fine.

Polymer change selected bar color in tab

I tried to change the color of the bottom bar in the tab selected but without success. I can change the background color and the color of the text but not of the bar.. By the way this is what i've done:
<paper-tabs selected="0" >
<paper-tab>TAB1</paper-tab>
<paper-tab>TAB2</paper-tab>
<paper-tab>TAB3</paper-tab>
</paper-tabs>
<style shim-shadowdom>
body.core-narrow {
padding: 8px;
}
paper-tabs, core-toolbar {
background-color: #00bcd4;
color: #fff;
box-shadow: 0px 3px 2px rgba(0, 0, 0, 0.2);
}
core-toolbar paper-tabs {
box-shadow: none;
}
paper-tabs[noink][nobar] paper-tab.core-selected {
color: #db352c;
}
paper-tabs.transparent-teal {
background-color: transparent;
color: #00bcd4;
box-shadow: none;
}
paper-tabs.transparent-teal::shadow #selectionBar {
background-color: #00bcd4;
}
paper-tabs.transparent-teal paper-tab::shadow #ink {
color: #00bcd4;
}
h3 {
font-size: 18px;
font-weight: 600;
}
</style>
The color i want is color: #db352c; but the bar is still and always yellow!! How can i change it?
Following this Link: polymerElements/paper-fab
Example Code:
paper-fab {
--paper-fab-background: #db352c;
--paper-fab-keyboard-focus-background: red;
}
The docs show that there is a custom property to let you change the colour of the selection bar:
--paper-tabs-selection-bar-color

Highlighting a tag using CSS

I have an HTML tag I created using CSS3. I would like to 'highlight' a particular tab. Ideally, I'd like to have a glow around the tag that shows it is active. I'm using ':after' to create the shape of the tag, but this doesn't allow me to highlight around the actual shape.
Here's a Fiddle:
http://jsfiddle.net/nocztpxv/2/
HTML
<a href="#" class="tag">
InsertHTML
</a>
CSS
.active{
border: 1px solid rgb(246, 255, 0);
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05) inset, 0px 0px 8px rgba(255, 252, 14, 0.6);
}
As you can see, the highlight is around everything except the arrow/triangle part. Does anyone know how I could have the same highlighted look around the arrow/triangle as well?
There is one solution that I can think of, but requires slight modification to your DOM. The solution is by wrapping the link text within a <span> element, and then instead of using borders for the triangle, we will use a rotated rectangle for that effect. However, since the background has to be higher up in the z-index than the rotated rectangle, nesting is needed (so that we declare the blue background on the <span> element instead.
See fiddle here: http://jsfiddle.net/teddyrised/nocztpxv/6/ For a three-dimensional visualisation of the stack, see here: http://jsfiddle.net/teddyrised/nocztpxv/8/
As there are only two pseudo-elements possible and you are using both ::before and ::after for stylistic purposes already, we can only use an additional level of nesting:
<a href="#" class="tag">
<span>InsertHTML</span>
</a>
<a href="#" class="tag active">
<span>InsertHTML</span>
</a>
<a href="#" class="tag">
<span>InsertHTML</span>
</a>
For the CSS (note: you might want to add vendor prefixes to the CSS transform property):
.tag {
font-family: Helvetica, Arial, sans-serif;
display: inline-block;
color: #fff;
position: relative;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
margin: 0 30px 0 0;
text-decoration: none;
}
/* The rotated square */
.tag::after {
background-color: #588fe5;
display: block;
height: 27px;
width: 27px;
position: absolute;
top: 6px;
right: -13px;
content: "";
transform: rotate(45deg);
z-index: 1;
}
/* Nested span */
.tag > span {
display: inline-block;
background-color: #588fe5;
position: relative;
padding: 10px;
z-index: 2;
}
/* The white dot */
.tag > span::before {
background: #fff;
width: 10px;
height: 10px;
content: "";
display: inline-block;
border-radius: 20px;
margin: 0 5px 0 0;
}
/* Hover effects */
.tag:hover::after, .tag:hover > span {
background-color: #739fe4;
}
/* Active tag */
.tag.active, .tag.active::after {
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.05) inset, 0px 0px 8px rgba(255, 252, 14, 0.6);
}