I'm currently using stylesheet for my style in react-native. I found a css style that I need for my component unfortunately it has an :after and :before in css. How to use :after and :before in stylesheet in react-native.
Here's the sample css code that I'm trying to convert into react-native style sheet:
.ticket:before,
.ticket:after {
content: '';
display: block;
position: absolute;
top: 130px;
width: 60px;
height: 60px;
border-radius: 50%;
z-index: 2;
}
.ticket:before {
background: white;
left: -30px;
}
.ticket:after {
right: -30px;
background: white;
}
Css pseudo selectors such as ::after or ::before do not work in react-native, but if you want your styles to look as close to css as possible I would recommend using something like Styled Components. It works on both web and react-native.
Related
//Main.js
<SpanStyle className="texting-container">
<div className>Click Me</div>
</SpanStyle>
The component SpanStyle uses class tag "texting-container" to set the CSS attribute:
// sample.css
.texting-container {
pointer-events: none;
margin: 0%;
margin-bottom: 0%;
margin-top: 0%;
margin-left: 0%;
margin-right: 0%;
}
As of now ,setting pointer-events: none is the only way I can set my text tag to be able to "click through" the button it is nested within
The problem is, I'm using Styled Components in my project and instead of using the CSS method like I mentioned, I tried setting the same CSS attribute within the styled component definition, however it doesn't work at all (unlike the former method). Here is the styled component, hopefully somebody can direct me to why it isn't working as intended:
//Main.js
const SpanStyle = styled.span`
position: absolute;
top: 49%;
left: 37%;
transform: "translate(-50%, -50%)"
pointer-events: none
cursor: none;
`;
I'm trying to set an image on a :before pseudo element.
It works on all browsers except IE11 of course.
Here the positioning doesn't work as expected.
<ol>
<li>
:before
li {
position: relative;
}
li:before {
content: url('image.svg');
position: absolute;
width: 2.3em
top: 2.5em;
left: 1.2em;
}
The problem is that IE11 seems to have problems with the image content. It works with text but not with the content: url().
This is what text looks like with top: 0; left: 0;:
And this what the image looks like with top: 0; left: 0;:
Is there some special thing needed for IE11 to make this work. Or is it just not possible to do it in this way?
How would you position these elements so they work in most browsers and IE11?
Instead of using content, try using background-image property and adjust position as you need...
li:before {
content: '';
background-image: url('image.svg');
position: absolute;
display: block;
width: 2.3em;
height: //
background-size: //
top: 2.5em;
left: 1.2em;
}
I am building a ReactJS app and using Zurb Foundation 6. I am also using React Modal: https://reactcommunity.org/react-modal/#documentation.
I want to style the Modal launched through React Modal to look like Zurb Foundation's Reveal. The Reveal SASS looks like this:
// 28. Reveal
// ----------
$reveal-background: $white;
$reveal-width: 600px;
$reveal-max-width: $global-width;
$reveal-padding: $global-padding;
$reveal-border: 1px solid $medium-gray;
$reveal-radius: $global-radius;
$reveal-zindex: 1005;
$reveal-overlay-background: rgba($black, 0.45);
And my Modal CSS is like this:
.modal {
position: absolute;
width: 600px;
top: 20%;
left: 20%;
right: 20%;
bottom: 20%;
background-color: $white;
}
.OverlayClass {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba($black, 0.45);
}
How can I achieve this? I have been experimenting with #include, but no success. At the moment, the Modal I have is not aesthetically pleasing. Help is greatly appreciated.
.your-modal {
#extend .reveal;
/* write your custom css here */
}
instead of using .reveal, now you just need to use the start .your-modal for a modal container.
The foundation section you have there is just the config variables for the reveal. The rest of the .scss for the reveal is here https://github.com/zurb/foundation-sites/blob/develop/scss/components/_reveal.scss
You should be able to structure the rendered HTML from your component to match the elements and classes from Foundation, just avoid the Foundation JS.
I have a chunk of code that allows me to have a re-sizable border for my table but it doesn't show in Outlook.
.column1{
border: 2px solid #fff;
padding: 0.5em;
position: relative;
}
.column1:after {
content: '';
background-color: #CCC;
position: absolute;
left: 97.5%;
top: 10px;
bottom: 10px;
width: 1px;
}
I believe it is the :after selector that Outlook doesn't agree with. Is there a way around it?
Due to lack of support in Outlook for such selector as :after among many others, you won't be able to produce the same effect using CSS. See http://www.campaignmonitor.com/css/ for information on the available CSS abilities of major email clients.
I want to give an element a border-top with a tab at the right corner like this:
Since this will be a repeated element within an Adobe Business Catalyst template, I want it to be pure CSS or at least CSS and javascript, without the use of any images. Is there any way this can be done?
Since it's just a decorative element, it doesn't have to be cross-browser.
Have a look at this:
http://jsfiddle.net/8hB7E/
HTML:
<body>
<div class="element">
</div>
</body>
CSS:
body { background: #555 }
.element { background: #000; border-top: 2px solid #fff; height: 100px; position: relative; width: 300px; }
.element:after { background: #fff; content: " "; height: 10px; position: absolute; right: 0; top: 0; width: 20px; }
It utilises the :after pseudo-element (which I find to be really useful!)
For more info see here:
http://coding.smashingmagazine.com/2011/07/13/learning-to-use-the-before-and-after-pseudo-elements-in-css/
Unfortunately this won't work in IE7 or 6 - it's not core to the functionality of the website though, so I'd say it's ok as is.