I have this CSS styles which I want to change to styled-components in react:
.movie-page .movie-details {
display: flex;
flex-direction: column;
max-width: 800px;
margin: 20px auto 60px auto;
}
.movie-page .movie-details h1 {
line-height: 1.5em;
}
.movie-page .movie-details h1 span {
font-size: inherit;
font-weight: normal;
padding-left: 1rem;
color: #bbb;
line-height: inherit;
}
I'm a bit confused how does the tags nesting work. I'm doing this with styled-components:
const MovieDetails = styled.div`
display: flex;
flex-direction: column;
max-width: 800px;
margin: 20px auto 60px auto;
h1 {
line-height: 1.5em;
}
h1 span {
font-size: inherit;
font-weight: normal;
padding-left: 1rem;
color: #bbb;
line-height: inherit;
}
`;
Does this code seem to be ok? My h1 tag looks like p tag
You should be able to select like that. Bt you can also do like the following which will look neater:
const MovieDetailsHeader = styled.h1 `
line-height: 1.5em;
span {
font-size: inherit;
font-weight: normal;
padding-left: 1rem;
color: #bbb;
line-height: inherit;
}
`
Related
I applied the tailwind CSS and Ant design with my Next.js project.
I found the primary button got a white color.
But it shows own primary button color when the mouse over.
global.css
#tailwind base;
#tailwind components;
#tailwind utilities;
#layer base {
h1 {
#apply text-2xl;
}
h2 {
#apply text-xl;
}
/* ... */
}
#import '~antd/dist/antd.css';
Home.module.css
.container {
padding: 0 2rem;
}
.main {
min-height: 100vh;
padding: 4rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.footer {
display: flex;
flex: 1;
padding: 2rem 0;
border-top: 1px solid #eaeaea;
justify-content: center;
align-items: center;
}
.footer a {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
}
.title a {
color: #0070f3;
text-decoration: none;
}
.title a:hover,
.title a:focus,
.title a:active {
text-decoration: underline;
}
.title {
margin: 0;
line-height: 1.15;
font-size: 4rem;
}
.title,
.description {
text-align: center;
}
.description {
margin: 4rem 0;
line-height: 1.5;
font-size: 1.5rem;
}
.code {
background: #fafafa;
border-radius: 5px;
padding: 0.75rem;
font-size: 1.1rem;
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
Bitstream Vera Sans Mono, Courier New, monospace;
}
.grid {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
max-width: 800px;
}
.card {
margin: 1rem;
padding: 1.5rem;
text-align: left;
color: inherit;
text-decoration: none;
border: 1px solid #eaeaea;
border-radius: 10px;
transition: color 0.15s ease, border-color 0.15s ease;
max-width: 300px;
}
.card:hover,
.card:focus,
.card:active {
color: #0070f3;
border-color: #0070f3;
}
.card h2 {
margin: 0 0 1rem 0;
font-size: 1.5rem;
}
.card p {
margin: 0;
font-size: 1.25rem;
line-height: 1.5;
}
.logo {
height: 1em;
margin-left: 0.5rem;
}
#media (max-width: 600px) {
.grid {
width: 100%;
flex-direction: column;
}
}
JSX code is like the following.
import * as React from "react";
import { Button, Table } from "antd";
import FishbowlLayout from "../../components/FishbowlLayout";
export function Index() {
return (
<div>
# FishbowlLayout uses Layout from Ant design.
<FishbowlLayout>.
<div className="grid grid-cols-6 gap-4">
# Button
<Button className="col-end-6 col-span-1 ..." type="primary">
New project
</Button>
# Table
<div className="col-span-5 ">
<Table dataSource={dataSource} columns={columns} />;
</div>
</div>
</FishbowlLayout>
</div>
);
}
export default Index;
In your tailwind.config file add the following:
corePlugins: {
preflight: false
}
it's explained in a lot more detail in this video: https://www.youtube.com/watch?v=oG6XPy1t1KA&ab_channel=TailwindLabs
edit: typo, thanks for pointing it out Fabio
Interesting. Preflight is a set of base styles that Tailwind applies, and it is setting the button background color to transparent.
The solution is to disable Preflight in tailwind.config.js; see the Tailwind documentation.
A simple solution would be to override the CSS as shown below:
.ant-btn:not([disabled]):hover {
background:#faad14 !important;
}
How to get the text wrapped under the points?
https://codepen.io/neginbasiri/pen/ZEGReRZ
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3
pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt">
Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13">
<span>3</span></sup> </span></p></div>
In the example switch should show under 16,000.
.bUhvVh {
display: flex;
margin-bottom: 20px;
width: 300px;
}
.iBQvHK {
color: #e40000;
font-size: 24px;
margin-right: 10px;
border: 1px solid red;
width: 20px;
}
.icon--icon--base--17 {
height: 1em;
min-width: 1em;
vertical-align: middle;
fill: currentColor;
}
.cPwDGx {
font-family: Ciutadella Regular;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
.enMiay {
float: left;
font-family: Ciutadella Medium;
margin-right: 4px;
position: relative;
color: #323232;
}
.dufgDt {
margin: 0;
font-family: 'Ciutadella Regular',sans-serif;
font-size: 18px;
color: #555;
letter-spacing: normal;
line-height: 1.5;
}
<div class="pointLine__PointLine-wgyo1p-1 bUhvVh">
<svg class="icon--icon--base--17 pointLine__RooIcon-wgyo1p-0 iBQvHK">IMAGE</svg>
<div class="pointLine__Content-wgyo1p-2 cPwDGx"><div class="pointLine__Point-wgyo1p-3 pointLine__DefaultPoint-wgyo1p-4 enMiay">16,000</div><p class="Text__StyledText-zy9rxk-0 dufgDt"> Points when you join or switch <span id="super-node-187"><sup class="super--super--root--13"><span>3</span></sup> </span></p></div>
</div>
Remove display: flex; flex: 1 from .cPwDGx.
Remove display: inline-block from .enMiay and add float: left for this element.
Update width to min-width for icon--icon--base--17. It will not shrink if text is larger.
Refer : https://codepen.io/bala_tamizh/pen/WNvyEPg
I got it this far:
Jsfiddle
How can I change the css of the span so it's vertically centered to the h1 on the left of it?
Hope it's not to complicated!
Your best bet is using Flex styles.
Remove all styles for '.title i', '.title span', '.title h1'
Edit title as below:
Flex title style:
.title {
width: 100%;
margin: 30px auto;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
justify-content: center; - This re-aligns your H1, dash, and span in the middle.
align-items: center; - This gives you that vertical alignment.
Add a wrapper around h1 and span, then set it as a inline-flex. The wrapper will be centered because of the text-align with title.
Fiddle
.title {
width: 100%;
margin: 30px auto;
text-align: center;
}
.wrapper {
display: inline-flex;
justify-content: flex-start;
align-items: center;
}
.title i {
color: var(--grey-500);
}
.title span {
font-size: var(--caption);
line-height: 40px;
color: #9E9E9E;
}
.title h1 {
color: var(--black);
font-size: var(--h1);
text-align: center;
font-weight: 500;
margin: 65px auto;
}
<div class="title">
<div class="wrapper">
<h1>Title 1</h1> <i class="material-icons separateTitleType">remove</i> <span>Page</span>
</div>
</div>
Add this code to .title
display: flex;
justify-content:center;
align-items:center;
Also, i removed margin: 65px auto from h1 so it wouldn't take all the place in flex-container.
/* Titles */
.title {
width: 100%;
margin: 30px auto;
text-align: center;
display: flex;
justify-content:center;
align-items:center;
}
.title i {
color: var(--grey-500);
}
.title span {
font-size: var(--caption);
line-height: 40px;
color: #9E9E9E;
}
.title h1 {
color: var(--black);
font-size: var(--h1);
text-align: center;
font-weight: 500;
}
:root {
--black: #000000;
--h1: 2.125em;
--caption: 0.875em;
--grey-500: #9E9E9E;
}
/* fallback */
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(https://fonts.gstatic.com/s/materialicons/v22/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
body {
font-family: 'Roboto', sans-serif;
background-color: #fff;
}
<div class="title">
<h1>Title 1</h1> <i class="material-icons separateTitleType">remove</i> <span>Page</span>
</div>
I have this page: food menu
I have placed a clear on the dish title with the following css:
#media (max-width: 768px) {
.dish: {text-align:center;}
.dishTitle {
clear: right;
display: block;
}
.dish img {clear: left;}
}
For some reason it is not clearing. If you inspect the dishTitle div it shows up and if I remove the display attribute it does clear. How can I get the images and price to be centered on a separate line below the dishNumber and dishTitle divs? Also, I have the entire dish item wrapped in the .dish div and have set it to text-align: center; but nothing is centering. I want it to look right on mobile devices and right now it just bunches everything together. Here is all of my CSS if it helps:
.dish {
text-align: left;
}
.dishNumber {
font-size: 18px;
display: inline;
line-height: 24px;
vertical-align: middle;
color: #FF6600;
margin-right: 2px;
}
.dishTitle {
font-size: 18px;
display: inline;
line-height: 24px;
vertical-align: middle;
color: #000066;
margin-bottom: 4px;
}
.dishPhoto {
padding-right: 8px;
padding-left: 8px;
display: inline;
}
.dishPrice {
font-size: 18px;
clear: right;
display: inline;
float: right;
line-height: 32px;
vertical-align: middle;
color: #000066;
}
.dishDescription {
font-size: 14px;
margin-bottom: 6px;
font-style: italic;
padding-right: 44px;
}
.dish img {
max-height: 22px;
}
Thanks for any help.
HTML
<div>
<div></div>
</div>
CSS
div > :first-child:after {
background-color: orange;
color: #fff;
font-family: sans-serif;
font-size: 50px;
line-height: 50px;
text-align: center;
vertical-align: middle;
-webkit-font-smoothing: antialiased;
content: "hello world";
display: block;
font-size: 50px;
height: 160px;
line-height: 160px;
margin-top: 14px;
font-weight: normal;
}
div > :first-child:after:hover {
background-color: #44b800;
}
Fiddle
http://jsfiddle.net/VSBr6/
Basically, all I want to do is change the background-color on hover but it doesn't seem to work.
You can do it like this:
div:first-child:hover::after {
background-color: #44b800;
}