Hide checkbox using css - css

I have the code, which I get it from inspecting:
<td class=ox-list-pair style>
<input type="CHECKBOX" name="ox_CkSurvey_Sport__xava_selected" value="selected:0" onclick="openxava.onSelectElement('CkSurvey','Sport','null','row=0,viewObject=xava_view',this.checked,'ox_CkSurvey_Sport__0',false,'','border-bottom: 1px solid;','',false,false,0,'xava_tab')">
</td>
I have tried to hide the checkbox but none of them success.
My attempts:
input[type=checkbox].ox_CkSurvey_Sport__xava_selected {
display: none;
}
ox_CkSurvey_Sport__xava_selected {
display: none;
}
.ox_CkSurvey_Sport__xava_selected input[type="checkbox"]{
display:none;
}
Please note that <td> is valid as it is inside <tr> as well as <table>.
Please help me. Thanks.

You should read up on CSS selectors.
https://www.w3schools.com/cssref/css_selectors.asp
You are trying to hide the check box with the class "ox_CkSurvey_Sport__xava_selected", but that doesn't exist.
You need to do this:
input[type=checkbox][name=ox_CkSurvey_Sport__xava_selected] {
display: none;
}

Is your <td> valid? What makes a <td> valid is:
It must be in a <tr>
That <tr> must be in a <table>
Technically <tr> must be in a <tbody>, <thead>, or <tfoot> but the browser will create a <tbody> by default if there's a <table>.
In the demo there's:
a <table>, <tr>, <td>, and your messy checkbox.
a <td> and a simple checkbox.
Note: The selector is td.ox-list-pair > input[type="checkbox"] and it successfully hides the messy checkbox and fails to hide the simple checkbox. So as you can see that the browser will ignore an invalid <td> and everything within it. I'm going out on a limb and assume that your <td> is not inside a <tr> and/or <table>.
Demo
$('td.ox-list-pair > input[type="checkbox"]').css('display', 'none');
b {
color: red
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<td class='ox-list-pair' style>
<input type="CHECKBOX" name="ox_CkSurvey_Sport__xava_selected" value="selected:0" onclick="openxava.onSelectElement('CkSurvey','Sport','null','row=0,viewObject=xava_view',this.checked,'ox_CkSurvey_Sport__0',false,'','border-bottom: 1px solid;','',false,false,0,'xava_tab')">I'm
in a valid cell
</td>
</tr>
</table>
<td class='ox-list-pair'>
<input type="CHECKBOX">I'm in an <b>invalid</b> cell
</td>

Related

css has() selector weirdness (chrome)

Recently, I had a case where the has() selector seemed to provide the answer to a problem. And I found that it isn't. And not because FireFox doesn't support it. (Although that is a problem too.)
To show this I made a codepen lookahead selector is weird
The bit with class v1 is the first solution I came up with. And I have no idea why it doesn't work.
When I saw v1 didn't work, I came up with the alternative with class v2. That also didn't work. But I could at least understand why.
Considering that the halves that did work cover all that I need, I made the one with class v3.
Intrigued by v1 not working, I also made v1a,to see if I could figure out which part of the selection doesn't do what I think it does.
And that shows just how weird has() is. Adding the rule for the background of the table flipped the does/doesn't work on the rules.
Also, by accident, I ended up wildly moving across the elements of the table of v1. And at some moment...both rules started working. For v1a, the same. If you want to see this, just make circles on the v1 table hitting all the tds until you see both spans on the right responding.
I tried with both Chrome and Edge. FireFox simply doesn't support it. And I don't happen to have Safari handy to try it on.
Can anyone give an explanation so I understand what is going on? Preferably with pointers to getting something that works in a way that makes a bit more sense.
td {
border: 1px solid black;
}
table {
background-color: skyblue;
margin: 10px;
}
span {
display: inline-block;
padding: 5px;
}
.v1a:has(td .span1:hover) {
background-color: green;
}
.v1:has(td .span3:hover) tr td .span2, /* Ok */
.v1:has(td .span1:hover) tr td .span4 { /* NOk. Why? */
background-color: red;
}
.v2 tr:has(td .span3:hover)~tr td .span2, /* NOk, but I know why. */
.v2 tr:has(td .span1:hover)~tr td .span4 { /* Ok */
background-color: red;
}
.v3:has(td .span3:hover) tr td .span2, /* Ok */
.v3 tr:has(td .span1:hover)~tr td .span4 { /* Ok */
background-color: red;
}
<table class="v1">
<tr>
<td>
<span class="span1">1</span>
</td>
<td>
<span class="span2">2</span>
</td>
</tr>
<tr>
<td>
<span class="span3">3</span>
</td>
<td>
<span class="span4">4</span>
</td>
</tr>
</table>
<table class="v1 v1a">
<tr>
<td>
<span class="span1">1</span>
</td>
<td>
<span class="span2">2</span>
</td>
</tr>
<tr>
<td>
<span class="span3">3</span>
</td>
<td>
<span class="span4">4</span>
</td>
</tr>
</table>
<table class="v2">
<tr>
<td>
<span class="span1">1</span>
</td>
<td>
<span class="span2">2</span>
</td>
</tr>
<tr>
<td>
<span class="span3">3</span>
</td>
<td>
<span class="span4">4</span>
</td>
</tr>
</table>
<table class="v3">
<tr>
<td>
<span class="span1">1</span>
</td>
<td>
<span class="span2">2</span>
</td>
</tr>
<tr>
<td>
<span class="span3">3</span>
</td>
<td>
<span class="span4">4</span>
</td>
</tr>
</table>

Why does Microsoft Edge ignore td width?

I expected all browsers behave the same, which is setting all tds in a table to the width of the largest width indication of all tds.
Take a look at the following examples:
https://jsfiddle.net/rpkbf4n6/
=> This one is displayed correct in FF/IE but wrong in Edge (the very long text is not wrapped)
https://jsfiddle.net/8oa4fw2u/
=> This one is displayed correct in FF/IE/Edge
Why is this? I don't like to give all tds the width attribute and I don't like to give the width attribute to the largest content td (because the content is filled dynamically, so I don't know which is the largest)
Add a DIV above the table and use table-layout: fixed then it works with Edge
<div class="wrap">
<table class="table">
<tbody>
<tr>
<td style="width:100px;">
<span>Text</span>
</td>
<td>
<input style="width:160px;">
</td>
</tr>
<tr>
<td>
<span>Very very very very very long text</span>
</td>
<td>
<input type="checkbox">
</td>
</tr>
</tbody>
</table>
</div>
.wrap {
width: 500px;
}
.table {
width: 100%;
table-layout: fixed
}

Remove all tr elements unless tr>td>input has a class 'DontRemoveMe'

Sorry for the very specific title, couldn't think of how to say it in more general terms.
Assume you have a table and each row contains a cell that has an input, but some input fields have a class of 'DontRemoveMe'. How do you target every row except the 'DontRemoveMe' rows?
Manipulation of DOM Elements requires JavaScript. One way to achieve this is with jQuery:
function remove() {
$('tr:not(.dontRemoveMe)').remove();
}
.dontRemoveMe td {
background-color: green;
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr class="dontRemoveMe">
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Jon</td>
<td>Jones</td>
<td>33</td>
</tr>
</table>
<button onclick="remove()">Remove rows</button>
CSS (Not Yet Implemented):
Using CSS level 4 selectors, I believe it would be
tr:has(td>input:not(>>.DontRemoveMe))
However, those aren't implemented in any browser. So you would want to use javascript.
Javascript:
// Select all rows that don't contain a input.DontRemoveMe
let rows = Array.from(document.querySelectorAll("tr")).filter(x => !(x.querySelector("input.DontRemoveMe")));
// Add a special class to these rows so we can target them with CSS
rows.forEach(x => x.classList.add("selected"));
td {
padding: 8px; /* Padding for all rows to make background visible */
}
.selected {
background: red;
}
<table>
<tr>
<td><input type="text" value="selected" />
</td>
</tr>
<tr>
<td><input class="DontRemoveMe" type="text" value="not selected" />
</td>
</tr>
<tr>
<td>
<input type="text" value="selected" />
</td>
</tr>
</table>
Here is an old school javascript way.
Find all the tr tags then find any children with class DontRemoveMe, if it doesn't find any add a .hide class to the current row.
But, honestly I'd question the reason you want to do it like this, chances are there is a more sensible way.
var tr = document.getElementsByTagName('tr');
var i = 0;
var length = tr.length
for (; i < length; i++) {
var dontRemove = tr[i].getElementsByClassName('DontRemoveMe')
if (!dontRemove.length) {
tr[i].classList.add('hide')
}
}
td {
color: #ededed;
}
.red {
background-color: #ff3030;
}
.blue {
background-color: #6495ED;
}
.hide {
display: none;
}
<table>
<tr class="red">
<td>Normal</td>
<td>Normal</td>
<td class="DontRemoveMe">Don't Remove Me</td>
</tr>
<tr class="blue">
<td>Can't see me</td>
<td>Can't see me</td>
<td>Can't see me</td>
</tr>
<tr class="red">
<td class="DontRemoveMe">Don't Remove Me</td>
<td>Normal</td>
<td class="DontRemoveMe">Don't Remove Me</td>
</tr>
</table>

When user inputs "-" it does not show up in input box in Chrome, but works in Firefox

I have no problem getting this to work in Firefox. The program is that Chrome hides the text below the bottom of the input box. I think Chrome is only using the body tag's font and height and ignoring class completely as a stupid thing with stupid values that it thinks is not valid because it results in a super thin input box, which is by design. The user is only suppose to put in " _ " to "underline" the letter.
NOTE: Flex boxes do not work because Flex box is all about the content moving to fit the screen. I am trying to do something more akin to a Word Find where the user would simply put a "=" in the in put box, to indicate that they are underlining the letter. I need the input boxes and the letters to line up both Vertically and Horizontally.
UPDATE:
Flex box will wrap to the next line after you've closed your screen enough. I do not want a code that thinks for me. I know where I want things. Besides, Flex boxes do not make INPUT boxes allow input that shows up! Flex boxes do NOT have a thing to do with input boxes. The problem is that Chrome needs a HACK to force its God Code to stop playing God on my page. This is why I think I will just throw out Chrome and just use Firefox. At least Firefox actually ALLOWS MY CSS instead of ignoring it because IT thinks that IT knows best!
Things I have tried:
Changing Font size both increasing and decreasing the size.
Commenting out/not commenting out height, vertical-align, line-height values.
Thanks!
EDIT: The HTML and Updated CSS, and gave the JS too.
<tr>
<td> </td>
<td class="grey"> Q </td>
<td class="grey"> A </td>
<td class="grey"> F </td>
<td class="grey"> O </td>
<td class="grey"> U </td>
<td class="grey"> R </td>
</tr>
<tr>
<td> </td>
<td><input class="zthin" type="text" name="c1" size="1"> </td>
<td><input class="zthin" type="text" name="c2" size="1"> </td>
<td><input class="zthin" type="text" name="c3" size="1"> </td>
<td><input class="zthin" type="text" name="c4" size="1"> </td>
<td><input class="zthin" type="text" name="c5" size="1"> </td>
</tr>
CSS Updated:
BODY {
background-color: #000000;
background-image: url(/w5jyz84kw0dle38f19s0xceydkoyjs/velvela/gaming/2/word/xw/xwcss/ngc3.jpg);
background-repeat: repeat-y;
background-position: top left;
border: 0px; height: 100%; width: 100%;
margin: 0px 0px 0px 0px;
}
input.zthin {
background-color: #c1c1c1;
border: 2px solid #0000ff;
font-size: 10pt;
height: 10pt;
line-height: 10pt;
padding:0px;
width:20px;
z-index: 1;
}
JS:
<script type="text/javascript">
function jyzcrossWord(){
if (document.form.c1.value=="-"
&& document.form.c2.value=="-"
&& document.form.c3.value=="-"
&& document.form.c4.value=="-"
&& document.form.c5.value=="-"
)
alert("Congratulations! All is correct!")
else {alert("Not correct. Please check your answers.")}
}
</script>
Lastly, when I put '-' into the input box, I do not see it at all. If put 'm' I only see the upper half of the 'm'. In Firefox, it shows up properly. Also, class grey does not matter, as that part of the css was not the issue. Thanks!

CSS - Style the title from the image tag

I'm trying to style the title from the image tag.
I have search other question but can´t it put working in my project.
But I can´t make any changes.
Someone can give me hand with this pls?
my code:
table.tablesorter tbody tr td a:hover img[title]:after
{
content: attr(title);
padding: 4px 8px;
color: #FFF;
background-color:black;
}
<table class="tablesorter" style="width:98% !important">
<thead>
<tr>
<th>
.....
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
..........
</td>
<td>
<a href="#Url.Action("Edit","Account", new { id=item.UserId })">
<img src="~/Content/images/icon_edit.png" title="Edit"/>
</a>
</td>
</tr>
</tbody>
<tfooter>
</tfooter>
</table>
It should be content: attr(title);, not content: attr(data-title); - you don't have a data attribute.
Also, it seems ::before and ::after pseudo-elements are not defined for img - you may have to use something else:
CSS Content attribute for IMG tag
Working Example (when the image is missing): http://jsfiddle.net/DMAFm/
Another example, with the title on the <a> tag: http://jsfiddle.net/DMAFm/1/

Resources