I have been having problem with table not wanting to change (everything else scales as it should) responsively using media queries on iOS, it works perfectly on android phones and tablets, but not on iOS. I have tried adding viewport meta tag, but it doesn't help. Anyone know how to fix it?
Part of media query that doesn't work:
table, thead, tbody, th, td, tr {
display: block;
max-width:100%;
}
th{
display:none;
}
td {
border: none;
position: relative;
padding-left: 50%;
font-size: 1em;
background-color: #F6F7FB;
}
td:before {
position: absolute;
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
line-height: 4em;
vertical-align: middle;
font-weight: bold;
}
td:nth-of-type(2):before { content: "test"; }
td:nth-of-type(3):before { content: "test"; }
td:nth-of-type(4):before { content: "test"; }
td:nth-of-type(5):before { content: "test"; }
td:nth-of-type(6):before { content: "test"; }
td:nth-of-type(7):before { content: "test"; }
I am not sure, but for me changing display of the isn't correct. Also the position relative/absolut in tables won't work in most cases. Is it possible for you, to change table structure to divs structure with display table and table-cell? I always do that, when need to make some big table responsive and there is no problem with that
Related
I need some help in a sizing question. If you view the following code in desktop browsers, everything is sized as it should be. If you try to open it on a mobile phone (I have tested it with several iPhones), the td (white with grey border) is not resized properly. The td element is resized correct, if there is a span element that's causing the overflow.
div.highlighter-rouge {
overflow-x: scroll;
}
div.highlight {
width: 100%;
}
.highlight {
display: inline-block;
}
.highlight {
background-color: #eeeeee;
}
pre.highlight {
margin-top: 0;
margin-bottom: 0;
}
pre code {
white-space: pre;
}
table {
margin: 15px 0;
padding: 0;
}
table {
word-wrap: anywhere;
}
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0;
}
table tr td {
border: 1px solid #cccccc;
text-align: left;
margin: 0;
padding: 6px 13px;
}
table tr th :last-child,
table tr td :last-child {
margin-bottom: 0;
}
table tr th :first-child,
table tr td :first-child {
margin-top: 0;
}
td.rouge-code>pre>span {
display: inline-block;
}
.highlight .nt {
color: #000080;
}
.highlight .s1 {
color: #d01040;
}
html {
-webkit-text-size-adjust: 100%;
}
<div class="language-bash highlighter-rouge">
<div class="highlight">
<pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2</pre>
</td>
<td class="rouge-code">
<pre>ausearch <span class="nt">-c</span> <span class="s1">'ajp-bio-0:0:0:0'</span> <span class="nt">--raw</span> | audit2allow <span class="nt">-M</span> my-ajpbio0000
semodule <span class="nt">-i</span> my-ajpbio0000.pp</pre>
</td>
</tr>
</tbody>
</table</code>
</pre>
</div>
</div>
I've tried many things now, but my level of knowledge about this, just leads to trial and error. If you don't really like the solution with tables, I can also create a version with the exact same behaviour without them.
https://codepen.io/ribbonCaptain/pen/GRrqgpE
.rouge-table td {
vertical-align: top;
}
.rouge-table td pre {
white-space: pre-wrap;
}
...will do it. See it here.
There's not much to explain.
I'm building a website in wordpress, using the 'Rookie' theme, and have installed the sportpress plugin, as well as an accordion plugin.
I'd like to display a table in accordions, but also make it display properly when on a mobile device. This is the webpage > http://wnu.054.myftpupload.com/fixtures-and-results/
I've sorted this for the majority of tables (fixtures for the month) using the following CSS:
.table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
#media only screen and (max-width: 40em) {
thead th {
display: none;
}
td, th {
display: block;
}
td[data-th]:before {
content: attr(data-th);
}
}
table {
border-spacing: 0;
}
td,
th {
padding: 0.5em;
}
th {
font-weight: bold;
text-align: left;
}
thead th {
background-color: #999;
color: white;
}
td > div {
float: right;
}
#media screen and (max-width: 500px) {
thead th {
display: none;
}
thead th:first-child:after {
content: "'s";
}
td, th {
display: block;
width: 100% !important;
}
td[data-th]:before {
content: attr(data-th);
border-radius: 10px 0px 0px 10px;
font-weight: bold;
min-width: 10rem;
display: inline-block;
}
The problem I've got is that I don't have access to edit the tables in Sportspress so I can't edit the table data on the Player stats table so that it includes the 'data-th="heading"' - meaning the headers don't display.
Without the CSS above, the sportspress table displays OK (not perfect, but not bad either), I was wondering if I can set it so that the sportspress table ignores the CSS I've set up (on the responsive view) or if there is a better way to do this? If possible, the sportpress table would display the headers, but I think I'd have to upgrade from the free version?
I'm trying to turn a hyperlink into an icon while turning the content text into a tooltip. The catch is I'm working in a place where I have only CSS to play with, and I can't modify the HTML or add any Javascript. I'm retrieving data from an external source in a table, and one of the columns is a hyperlink - this I want to transform into an icon with the text-content as a tooltip manner on hover.
Below snipped is how far I've gotten, is there any way of making the :hover part look, feel and behave more like a tooltip? Or is there perhaps another way completely to achieve what I'm after?
.external-link {
font-size: 0;
}
.external-link:after {
content: ' ';
background: url(https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) no-repeat;
display: inline-block;
height: 32px;
width: 32px;
}
.external-link:hover {
/* Well it shows the text, but it ain't pretty nor very functional.. */
font-size: initial;
}
Stack Overflow
It's a bit tricky, but it's achievable with modifying before and after pseudo-elements. You just have to write tooltip content in your content property, otherwise, you should modify your HMTL itself.
So your final code should be something like this:
.external-link {
font-size: 0;
}
.external-link::before {
content: 'Stack Overflow';
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text */
position: absolute;
left: 40px;
z-index: 1;
/* Fade in tooltip */
opacity: 0;
transition: opacity 0.3s;
}
.external-link::after {
content: ' ';
background: url(https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) no-repeat;
display: inline-block;
height: 32px;
width: 32px;
}
.external-link:hover.external-link::before {
/* Well it shows the text, but it ain't pretty nor very functional.. */
font-size: initial;
visibility: visible;
opacity: 1;
}
Stack Overflow
You can just edit your css like below. Just some idea. Not sure if you can write the tooltip text into css
.external-link {
font-size: 0;
position: relative;
}
.external-link:after {
content: ' ';
background: url(https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) no-repeat;
display: inline-block;
height: 32px;
width: 32px;
}
.external-link:before {
content: 'Text';
position: absolute;
display: inline-block;
height: auto;
padding: 2px 5px;
width: 100%;
display:none;
color: white;
font-size:initial;
background: #00000099;
bottom: -15px;
}
.external-link:hover:before {
/* Well it shows the text, but it ain't pretty nor very functional.. */
display:block;
}
Stack Overflow
I'm learning css and I came across an example that has the following code:
<body>
Hearts
Clubs
Spades
Diamonds
</body>
and css:
.CardLink {
display: block;
color: #666;
text-shadow: 0 2px 0 #efefef;
text-decoration: none;
height: 2.75rem;
line-height: 2.75rem;
border-bottom: 1px solid #bbb;
position: relative;
}
#media (min-width: 300px) {
.CardLink {
padding-left: 1.8rem;
font-size: 1.6rem;
}
.CardLink:before {
display: block;
}
}
.CardLink:before {
display: none;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
}
.CardLink_Hearts:before {
content: "❤";
}
.CardLink_Clubs:before {
content: "♣";
}
.CardLink_Spades:before {
content: "♠";
}
.CardLink_Diamonds:before {
content: "♦";
}
/*#media (min-width: 300px) {
.CardLink:before {
display: block;
}
}*/
The idea is when the viewport size is below 300px then the card icons are not displayed, otherwise, it shows them.
I was playing around with the code and I can't understand why we have to define #media (min-width: 300px) twice for the code to work as expected.
Why can't we just put the code in the last paragraph of the css to the section where media screen size belongs (good code reuse instead of declaring this again ) ?
If I do this then no icons are displayed (this is the code below).
Could anyone explain ? Check the plunker, this works as expected: https://plnkr.co/edit/MJAPdkgUegpUlJnkcQHg?p=preview
Because you're working with Cascading Style Sheets.
A cascade is like a waterfall: The rendering engine starts at the top of the source document and works its way down.
In this case, it sees your media query. Then it sees the rest of your code, which takes precedence because it comes later.
For instance, let's say your stylesheet had this:
div { color: red; }
div { color: blue; }
div { color: red; }
Your text color will be red.
In this case:
div { color: red; }
div { color: blue; }
Your text color will be blue.
In both cases, CSS picks the last declaration in the stylesheet.
If you want your media query to take precedence, put it at the end of your code.
(It seems simple and often it is. Just make sure to learn about CSS specificity.)
It's about the placement, put the media query after the :before's and it will be ok
.CardLink {
display: block;
color: #666;
text-shadow: 0 2px 0 #efefef;
text-decoration: none;
height: 2.75rem;
line-height: 2.75rem;
border-bottom: 1px solid #bbb;
position: relative;
}
.CardLink:before {
display: none;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
}
.CardLink_Hearts:before {
content: "❤";
}
.CardLink_Clubs:before {
content: "♣";
}
.CardLink_Spades:before {
content: "♠";
}
.CardLink_Diamonds:before {
content: "♦";
}
#media (min-width: 300px) {
.CardLink {
padding-left: 1.8rem;
font-size: 1.6rem;
}
.CardLink:before {
display: block;
}
}
Hearts
Clubs
Spades
Diamonds
In Firefox the SVG icon won't display. It is displayed in every other browser. Any idea why? Is this not meant to be supported?
HAML
.contact-form__error
.contact-form__error--icon
.contact-form__error--text Something went wrong. Please try again later.
CSS
.contact-form__error {
color: red;
font-size: 12px;
margin-top: 5px;
position: absolute;
line-height: 1em;
}
.contact-form__error--icon {
// content: image-url('icons/alert_error.svg');
content: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjIiIGJhc2VQcm9maWxlPSJ0aW55IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSIjZTgzOTJlIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01Mi42IDYwYy0xIDMuNC00LjEgMy41LTUuMiAwLTEuMi00LTUuNC0yMy42LTUuNC0zMy41IDAtMTIuOSAxNi4yLTEzIDE2LjIgMCAwIDEwLTQuNSAzMC01LjYgMzMuNXpNNTAgODYuNGMtMy45IDAtNi42LTMtNi42LTYuOSAwLTQgMi44LTcgNi42LTcgNCAwIDYuNiAzIDYuNiA3IDAgMy45LTIuNiA2LjktNi42IDYuOXpNNTAgMEMyMi40IDAgMCAyMi40IDAgNTBzMjIuNCA1MCA1MCA1MCA1MC0yMi40IDUwLTUwUzc3LjYgMCA1MCAweiIvPjwvc3ZnPg==');
width: 15px;
height: 15px;
vertical-align: text-bottom;
margin-right: 4px;
display: inline-block;
}
.contact-form__error--text {
display: inline-block;
vertical-align: middle;
}
http://codepen.io/Lightheaded/pen/NGZWyj
Attach it on :before or :after instead
.contact-form__error--icon:before {
content: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjIiIGJhc2VQcm9maWxlPSJ0aW55IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSIjZTgzOTJlIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01Mi42IDYwYy0xIDMuNC00LjEgMy41LTUuMiAwLTEuMi00LTUuNC0yMy42LTUuNC0zMy41IDAtMTIuOSAxNi4yLTEzIDE2LjIgMCAwIDEwLTQuNSAzMC01LjYgMzMuNXpNNTAgODYuNGMtMy45IDAtNi42LTMtNi42LTYuOSAwLTQgMi44LTcgNi42LTcgNCAwIDYuNiAzIDYuNiA3IDAgMy45LTIuNiA2LjktNi42IDYuOXpNNTAgMEMyMi40IDAgMCAyMi40IDAgNTBzMjIuNCA1MCA1MCA1MCA1MC0yMi40IDUwLTUwUzc3LjYgMCA1MCAweiIvPjwvc3ZnPg==');
}
http://codepen.io/anon/pen/WQqbbM