I started using react Bootstrap and I'm trying to change the background-color of my accordion and also take the focus off when I click on it, but I'm not getting it. How can I change accordion style?
Here is my code:
import { Accordion} from 'react-bootstrap';
import './App.css';
function App() {
return (
<>
<Accordion>
<Accordion.Item eventKey="0">
<Accordion.Header style={{ backgroundColor: '#343a40' }}>Accordion Item #1</Accordion.Header>
<Accordion.Body>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.
</Accordion.Body>
</Accordion.Item>
</Accordion>
</>
);
}
export default App;
.accordion-button {
background-color: gray !important;
}
.accordion-button:focus {
box-shadow: none;
}
.accordion-button:not(.collapsed) {
color: #212529;
}
https://codesandbox.io/s/optimistic-lalande-ojusme
Related
I'm trying to style a <div> only if one its paragraph gets moused-hover, while also excluding some sections from getting styled. Here is an example of HTML:
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. <span class=foo'>Ut enim ad minim veniam</span>, quis
nostrud exercitation <span class='foo'>ullamco laboris nisi</span> ut aliquip ex ea commodo
consequat.</p>
<p class='bar'>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.</p>
<div>
For the CSS, I tried:
div:has(.bar:hover) .bar {
color: blue
}
div:has(.bar:hover) :not(.foo) {
color: grey
}
and:
div:has(.bar:hover) .bar {
color: blue
}
div:has(.bar:hover):not(.foo) {
color: grey
}
but none of these options accomplish what I would like.
I would like the first paragraph except for both span to get colored in grey and the second paragraph to get colored in blue. However with my current code, the first paragraph including the span gets coloured in grey and the second in blue: it is not excluding the span from getting styled.
Is there a way to accomplish what I'm trying to do?
Something like this?
p:not(.bar):hover {
color: blue;
}
.foo {
color: initial !important;
}
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <span class=foo>Ut enim ad minim veniam</span>, quis nostrud exercitation <span class=foo>ullamco laboris nisi</span> ut aliquip ex ea commodo consequat.</p>
<p class=bar>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div>
You will need at least 3 rules.
div:has(.bar:hover) .bar {
color: blue
}
div:has(.bar:hover) p {
color: grey
}
div:has(.bar:hover) p .foo {
color: initial;
}
<div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. <span class="foo">Ut enim ad minim veniam</span>, quis nostrud exercitation <span class="foo">ullamco laboris nisi</span> ut
aliquip ex ea commodo consequat.
</p>
<p class="bar">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<div>
Here's a sample:
div {
height: 0;
overflow: hidden;
padding: 12px;
background: tan;
}
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
Is there a way to prevent padding from increasing the size of the div? Some threads suggest using box-sizing: border-box, but it doesn't seem to work in this case.
Replace it with margin by adding an extra div
div.box {
height: 0;
overflow: hidden;
background: tan;
}
div.box div {
margin: 12px;
}
<div class="box">
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
Or consider some hack with pseudo element:
div.box {
height: 0;
overflow: hidden;
background: tan;
padding: 0 15px; /* horizontal padding */
}
div.box:before,
div.box:after {
content: "";
display: block;
height: 12px; /* vertical padding */
}
<div class="box">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
If you are there for extra space, you can use {margin} instead which will only add space outside of the ““ box. Also if you want spacing between the text, you can use css property {line-height}.
I am trying to creating PDF from html using wkhtmltopdf libraray (https://github.com/wkhtmltopdf/wkhtmltopdf)
But ihave issue in creating two column pdf like newparers .
This issue is listed in a number of Posts, However, no solution is provided.
Using CSS,
.newsection { -webkit-column-count: 2; /* Chrome, Safari, Opera /
-moz-column-count: 2; / Firefox */
column-count: 2;}
does not render PDF with Newspaper style columns.
Desired output shown below;
try this brother.. :)
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1872#issuecomment-50742814
/* docs: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1872#issuecomment-50742814 */
.container-two-row {
/* You *must* define a fixed height which is
large enough to fit the whole content,
otherwise the layout is unpredictable. */
height: 28em;
/* Width and count aren't respected, but you
have to give at least some dummy value (??). */
-webkit-columns: 0 0;
/* This is the strange way to define the number of columns:
50% = 2 columns, 33% = 3 columns 25% = 4 columns */
width: 50%;
/* Gap and rule do work. */
-webkit-column-gap: 1px;
-webkit-column-rule: 1px solid black;
text-align: left;
}
.height-35em {
height: 35em;
}
.mt-15 {
margin-top: 15px;
}
<div class="container-two-row height-35em mt-15">
<strong>An Article</strong>
<div>
1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div>
2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div>
3. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div>
4. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
I've noticed an anomaly in Edge and IE when using flexbox with scrolling columns coupled with a horizontal scroll. The following codepen demonstrates correct functionality in Chrome and FireFox; however, there is an extra scroll bar on the very right of the view for a slight vertical overflow (the height of the horizontal scroll bar) that is only present in IE 11 and Edge:
Original Codepen Example
The raw html for reference:
<body>
<div class="app-master">
<div class="app-sidebar-spacer">
</div>
<div class="app-content">
<div class="app-header">
<div class="ui secondary small menu">
<a class="right item">
<div>
<span>happy text</span>
</div>
</a>
</div>
</div>
<div class="app-work-zone">
<div class="app-zone-content">
<div class="ui segment app-zone-segment">
</div>
</div>
<div class="app-zone-buffer">
</div>
<div class="app-zone-content">
<div class="ui segment app-zone-segment">
<div>
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." "Lorem
ip"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
sum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." "Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." "Lorem
ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</div>
</div>
</div>
<div class="app-zone-buffer">
</div>
<div class="app-zone-content">
<div class="ui segment app-zone-segment">
</div>
</div>
<div class="app-zone-buffer">
</div>
</div>
</div>
</div>
</body>
The raw css for reference:
html,
body {
height: 100%;
margin: 0;
min-height: 100%;
padding: 0;
}
.app-master {
display: flex;
flex-direction: row;
height: 100%;
}
.app-sidebar-spacer {
flex: 0 0 215px;
background-color: #2959a5;
}
.app-content {
flex: 1 1 auto;
display: flex;
flex-direction: column;
overflow-x: auto;
}
.app-header {
min-height: 43px;
}
.app-header>.ui.menu {
width: 100%;
}
.app-work-zone {
flex: 1 1 auto;
display: flex;
flex-direction: row;
min-height: 0;
}
.app-zone-content {
flex: 1 1 0;
min-width: 600px;
}
.app-zone-buffer {
width: 2px;
text-align: center;
}
.app-zone-segment {
height: 100%;
overflow-y: auto;
}
Notes:
I have semantic-ui loading in the codepen for basic styling, but the layout is developed using pure flexbox (not the semantic grid system).
Semantic ui already uses normalizer, so it is turned off in the codepen css.
In codepen I have "autoprefixer" turned on.
When viewing in IE, adjust the height of the preview window, and the preview window's vertical scroll bar will suddenly show scrolling.
All of my custom classes are prefixed with "app-".
Below are pictures of what seems to be a working implementation of this concept by the folks over at Asana; however, I am struggling to understand the implementation.
Image 1) With the window collapsed resulting in correct horizontal scrolling in Edge, no content hidden at the bottom of the screen, and no extraneous scroll bar at the very left of the view:
Image 2) With the window expanded (and no horizontal scrolling in Edge to demonstrate no content was hidden when horizontal scrolling was in effect):
So, is this actually a bug in IE and Edge, or does the seemingly functional implementation by Asana demonstrate a work around?
Edit 1) Added more in-depth description of the anomaly.
Edit 2) Added updated codepen link to track cross browser progress.
Edit 3) Updated final codepen with functional hacks. Functionality should now look identical across IE11, Edge, Chrome, and FF. The complete functional hack list is:
#supports (-ms-ime-align: auto) and (not (object-fit: cover)) {
.app-content {
overflow-x: scroll;
}
}
#media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.app-content {
overflow-x: scroll;
}
}
The following media query reverts overflow-x to auto in browsers where it was set to scroll (see hacks just above this one) when the browser width is greater than 825px. This number is derived from the 225px used for the left side-nav, and the 200 px minimum used for each flexbox item to the right of the side-nav. This prevents an extraneous horizontal scroll bar in IE11 and Edge when browser width is greater than 825px.
#media (min-width: 825px) {
.app-content {
overflow-x: auto;
}
}
Final (updated with functional hacks) Codepen Example
This is obviously a bug (haven't found any bug report yet and will update when I do).
I have tested this with Edge on Windows 10 Fall Creators Update version (Microsoft EdgeHTML 16), and is now fixed and work as it should.
Here is another post about the same issue, where one workaround for IE is to use scroll instead of auto (overflow-x: scroll)
Updated based on a comment
This is an attempt to find a CSS based hack that will detect IE 11 and Edge 12-15.
This IE 11 CSS hack appears to work properly:
#media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
.app-content {
overflow-x: scroll;
}
}
For Edge this CSS hack appears proven to work:
The following hack seems to work to find Edge:
#supports (-ms-ime-align: auto) {
.app-content {
overflow-x: scroll;
}
}
Though this also catch Edge 16, but here we got lucky as Edge 16 added support for object-fit
So by simply check for both the (-ms-ime-align: auto) and (not (object-fit: cover)), we should be able to actually distinct Edge 12-15 from 16
#supports (-ms-ime-align: auto) and (not (object-fit: cover)) {
.app-content {
overflow-x: scroll;
}
}
As noted, Microsoft appears moving to remove as many -ms prefixed properties as possible in future MS Edge, though we don't mind, as we want to target the older versions that still has them
I have tested the above 2 CSS hacks with success on IE 11 and Edge 16 using this Codepen:
https://codepen.io/anon/pen/RZYeJo
If anyone find this not work on a specific Edge version, please let me know so I can keep this post up to date.
For you who prefer to use Javascript, here is a post with some interesting reading:
Instead of using prefixes I want to ask site visitors to upgrade their browser
I need to indent the first line of a paragraph on React Native. But the use of the common css text-indent property (textIndent) isn't compatible with React Native, and neither are pseudo-element selectors (like :first-line). Is there any way to do this without wrapping the whole line in <Text> tags and defining its own style? Which words will end up in the first line of a paragraph is somewhat indeterministic from one device's viewport to another device's viewport.
Use {'\t'}. Just like this:
<Text>{'\t'}Hi there</Text>
For a purely CSS solution.
//styles.js
text: {
paddingLeft: 10,
}
I was able to get the text-indent to work in my react webapp with the below syntax:
//info.js
import './App.css'
export default class Info extends React.Component {
static defaultProps = {
history: {
goBack: () => { }
}
}
render() {
return (
<div>
<Nav />
<div id='info'>
<h2>Info</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
);
}
}
//App.css
div#info p {
text-indent: 20px;
}