为了格式化段落,我使用text-align:justify
,但我有一个问题是单词之间有很大的空格。对于IE,解决方法是使用text-justify:distribute;
,但是Chrome不支持这个属性。我的问题是在Chrome和Firefox中应该使用什么。
大空格的示例:http://jsfiddle.net/L5drN/
为了格式化段落,我使用text-align:justify
,但我有一个问题是单词之间有很大的空格。对于IE,解决方法是使用text-justify:distribute;
,但是Chrome不支持这个属性。我的问题是在Chrome和Firefox中应该使用什么。
大空格的示例:http://jsfiddle.net/L5drN/
根据您的喜好,将负值用于单词间距。
例如:
text-align:justify;
word-spacing:-2px;
适合我,希望这能帮到你 :)
使用:
word-break: break-all;
完成!
text-align: justify;
配合此方法对我有效。 - Malindatext-justify: distribute
,因为它可以在支持的浏览器上改善结果,并且可以期望获得支持,因为它在CSS标准化轨道中(在CSS Text Module Level 3 WD中)。div.justify {
text-align: justify;
hyphens: auto;
-webkit-hyphens: auto;
word-spacing: -0.05em;
}
div.font {
font-size: 110%;
}
<div class="justify font">In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content. Lorem ipsum may be used as a placeholder before final copy is available. It is also used to temporarily replace text in a process called greeking, which allows designers to consider the form of a webpage or publication, without the meaning of the text influencing the design.</div>
text-align: justify;
text-justify: distribute;
text-align-last: left;
希望这会对您有所帮助。
hyphens: auto;
text-align: justify;
word-spacing: -0.5px;
text-align: start;
text-align:center
还是 word-spacing CSS 标签呢?
word-spacing:10px
我有一个替代方案来消除单词之间的大间距。首先,您应该知道text-align:justify
仅在您将文本组件呈现在更宽屏幕上时使用,所以在我的情况下,我正在使用它在卡片自定义组件上,因此我只需增加我的卡片组件的宽度,这有助于我,希望它也能帮助到您。
Card.js
import React from 'react';
import styles from './Card.module.css'
const Card = (props) => {
return (
<div className={styles.card}>
{props.children}
</div>
);
} ;
export default Card;
Card.module.css
.card {
height: 30rem;
width: 25rem;
margin: 0 20px 10rem;
text-align: justify;
}
高阶组件中的名片组件
import React, { useEffect, useState } from "react";
import projectStyles from "./project.module.css";
import Card from "../UX/Card";
import axios from "axios";
const Project = () => {
const [loadedProjects, setLoadedUsers] = useState([]);
useEffect(() => {
const fetchUsers = async () => {
try {
const responseData = await axios("api/projects");
setLoadedUsers(responseData.data.projects);
} catch (err) {}
};
fetchUsers();
}, []);
const displayHandler = (
<div className={projectStyles.projectHolder}>
{loadedProjects.map((project,index) => {
return (
<Card key={index}>
<img src={project.image} alt="project" height={225} width={345} style={{marginBottom:"20px"}}/>
<p style={{fontSize:'25px' , fontWeight:'bold'}}>{project.title}</p>
<p className={projectStyles.body}>{project.info}</p>
<h4>Technologies Used</h4>
<ul key={project.image}>
{project.technology.map((tech) => {
return <li key={tech}>{tech}</li>;
})}
</ul>
</Card>
);
})}
</div>
);
return <div>{loadedProjects ? displayHandler : 'Fetching Projects...'}</div>;
};
export default Project;