如何将具有三行三列的容器转换为四行两列

时间:2020-01-03 04:09:09

标签: reactjs bootstrap-4 flexbox

我在这里使用react和bootstrap。关于调整大小如何使每行两列和行数由css为四?我不想在这里使用javascript或jquery。

请切换到全屏视图

在调整大小时,我想要两列四行。

class Right extends React.Component {
render(){
return(
<div className="container">
<div className="row">
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse ry="10.26" rx="10.461" cy="10.643" cx="20.613" stroke-width=".393" paint-order="markers stroke fill"/><ellipse cx="20.613" cy="10.677" rx="9.542" ry="9.441" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/></svg>
<label className="icolabl">1</label>
</object>
</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse ry="10.26" rx="10.461" cy="10.643" cx="20.613" stroke-width=".393" paint-order="markers stroke fill"/><ellipse cx="20.613" cy="10.677" rx="9.542" ry="9.441" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse ry="8.521" rx="8.889" cy="10.61" cx="20.68" stroke-width=".33" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.638" rx="8.108" ry="7.841" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/></svg>
<label className="icolabl">2</label>
</object>

</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/></svg>
<label className="icolabl">3</label>
</object>

</div>
</div>
<div className="row">
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/></svg>
<label className="icolabl">4</label>
</object>

</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/></svg>
<label className="icolabl">5</label>
</object>

</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/></svg>
<label className="icolabl">6</label>
</object>

</div>
</div>
<div className="row">
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/></svg>
<label className="icolabl">7</label>
</object>

</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/><ellipse cx="20.88" cy="10.977" rx="2.728" ry="2.059" stroke-width=".09" paint-order="markers stroke fill"/><ellipse ry="1.895" rx="2.488" cy="10.984" cx="20.88" fill="#fff" stroke-width=".082" paint-order="markers stroke fill"/></svg>
<label className="icolabl">8</label>
</object>

</div>
<div className="col-lg">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/><ellipse cx="20.88" cy="10.977" rx="2.728" ry="2.059" stroke-width=".09" paint-order="markers stroke fill"/><path d="M20.88 9.09c-.66 0-1.293.2-1.76.555s-.73.838-.73 1.34c0 1.047 1.114 1.895 2.488 1.895s2.488-.848 2.488-1.895c0-.503-.262-.985-.73-1.34s-1.1-.555-1.76-.555z" fill="#fff" paint-order="markers stroke fill" stroke-width=".082"/><ellipse ry="1.061" rx="1.947" cy="11.115" cx="21.06" stroke-width=".055" paint-order="markers stroke fill"/><path d="M21.06 10.142c-.47 0-.923.103-1.256.286s-.52.432-.52.69c0 .54.795.976 1.776.976s1.776-.437 1.776-.976c0-.26-.187-.507-.52-.69s-.785-.286-1.256-.286z" fill="#fff" stroke-width=".05" paint-order="markers stroke fill"/></svg>
<label className="icolabl">9</label>
</object>

</div>
</div>
</div>
);
}
}


class Block extends React.Component {
render(){
return(
<div className="container-fluid">
<div className="row"></div>
<div className="col-lg" style={{textAlign: "justified"}}>
<h1>This is the 
<span style={{color: "orange"}}> left </span>
part. I want changes in the 
<span style={{color: "green"}}> right </span>
part only </h1>
</div>
<div className="col-lg">
<Right />
</div>
</div>
);
}
}
ReactDOM.render(
    <Block />, document.getElementById('content')
);
.ico {
 color: midnightblue;
    fill: mediumspringgreen;
    stroke: midnightblue;
    cursor: pointer;
    text-align: center;
}
.ico:hover{
fill: orange;
    color: orange;
    stroke: orange;
    
}
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.0/umd/react-dom.production.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="content"></div>
</body>
</html>

2 个答案:

答案 0 :(得分:1)

在2020年是时候使用flexbox并停止网格了。这是怎么做:

import React from "react"

const styleBlock = { width: "50%" }

const Example = () => {
  return (
    <div style={{ display: "flex", flexWrap: "wrap", width: "100%" }}>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
    </div>
  )
}

export default Example

这是肮脏的解决方案,因为您的块正在扩展,因此,您一定要固定每个块的宽度,并在调整大小时使用flexWrap破坏行:

import React from "react"

const styleBlock = { width: 200 }

const Example = () => {
  return (
    <div style={{ display: "flex", flexWrap: "wrap", width: "100%" }}>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
      <div style={styleBlock}>block</div>
    </div>
  )
}

export default Example

如果要赋予块调整自身大小的能力,可以添加minWidth和maxWidth而不是固定宽度。

PS:您应该禁止使用自举程序,而应使用Material-UI。

答案 1 :(得分:1)

让我知道这是否是您想要的。

说明-网格具有col-lg col-md col-sm col-xs具有这四种视口选项,以使组件具有一定的宽度。

  • lg - large
  • md - medium
  • sm - small
  • xs - extra small

一行的总可用宽度为12个单位,因此编写 col-sm-6 意味着您希望在小屏幕上将该组件的总可用宽度一半尺寸。并写入 col-lg-4 意味着您要在大屏幕尺寸中给出可用总宽度的 1/3 。同样,您也可以使用其他屏幕尺寸。

class Right extends React.Component {
render(){
return(
<div className="container">
<div className="row">
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse ry="10.26" rx="10.461" cy="10.643" cx="20.613" stroke-width=".393" paint-order="markers stroke fill"/><ellipse cx="20.613" cy="10.677" rx="9.542" ry="9.441" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/></svg>
<label className="icolabl">1</label>
</object>
</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse ry="10.26" rx="10.461" cy="10.643" cx="20.613" stroke-width=".393" paint-order="markers stroke fill"/><ellipse cx="20.613" cy="10.677" rx="9.542" ry="9.441" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse ry="8.521" rx="8.889" cy="10.61" cx="20.68" stroke-width=".33" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.638" rx="8.108" ry="7.841" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/></svg>
<label className="icolabl">2</label>
</object>

</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/></svg>
<label className="icolabl">3</label>
</object>

</div>

<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/></svg>
<label className="icolabl">4</label>
</object>

</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/></svg>
<label className="icolabl">5</label>
</object>

</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/></svg>
<label className="icolabl">6</label>
</object>

</div>

<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/></svg>
<label className="icolabl">7</label>
</object>

</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/><ellipse cx="20.88" cy="10.977" rx="2.728" ry="2.059" stroke-width=".09" paint-order="markers stroke fill"/><ellipse ry="1.895" rx="2.488" cy="10.984" cx="20.88" fill="#fff" stroke-width=".082" paint-order="markers stroke fill"/></svg>
<label className="icolabl">8</label>
</object>

</div>
<div className="col-lg-4 col-sm-6">
<object className="ico">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42.333 21.167" height="80" width="160" stroke="#000"><ellipse cx="20.613" cy="10.643" rx="10.461" ry="10.26" stroke-width=".393" paint-order="markers stroke fill"/><ellipse ry="9.441" rx="9.542" cy="10.677" cx="20.613" fill="#fff" stroke-width=".36" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.61" rx="8.889" ry="8.521" stroke-width=".33" paint-order="markers stroke fill"/><ellipse ry="7.841" rx="8.108" cy="10.638" cx="20.68" fill="#fff" stroke-width=".302" paint-order="markers stroke fill"/><ellipse ry="7.01" rx="7.678" cy="10.743" cx="20.713" stroke-width=".278" paint-order="markers stroke fill"/><ellipse cx="20.713" cy="10.766" rx="7.004" ry="6.451" fill="#fff" stroke-width=".255" paint-order="markers stroke fill"/><ellipse cx="20.647" cy="10.877" rx="6.102" ry="5.701" stroke-width=".224" paint-order="markers stroke fill"/><ellipse ry="5.246" rx="5.566" cy="10.896" cx="20.647" fill="#fff" stroke-width=".205" paint-order="markers stroke fill"/><ellipse ry="4.488" rx="4.889" cy="10.844" cx="20.68" stroke-width=".178" paint-order="markers stroke fill"/><ellipse cx="20.68" cy="10.858" rx="4.459" ry="4.13" fill="#fff" stroke-width=".163" paint-order="markers stroke fill"/><ellipse cx="20.814" cy="10.877" rx="3.972" ry="3.471" stroke-width=".141" paint-order="markers stroke fill"/><ellipse ry="3.194" rx="3.623" cy="10.888" cx="20.814" fill="#fff" stroke-width=".129" paint-order="markers stroke fill"/><ellipse ry="2.881" rx="3.349" cy="10.877" cx="20.847" stroke-width=".118" paint-order="markers stroke fill"/><ellipse cx="20.847" cy="10.886" rx="3.054" ry="2.651" fill="#fff" stroke-width=".108" paint-order="markers stroke fill"/><ellipse cx="20.88" cy="10.977" rx="2.728" ry="2.059" stroke-width=".09" paint-order="markers stroke fill"/><path d="M20.88 9.09c-.66 0-1.293.2-1.76.555s-.73.838-.73 1.34c0 1.047 1.114 1.895 2.488 1.895s2.488-.848 2.488-1.895c0-.503-.262-.985-.73-1.34s-1.1-.555-1.76-.555z" fill="#fff" paint-order="markers stroke fill" stroke-width=".082"/><ellipse ry="1.061" rx="1.947" cy="11.115" cx="21.06" stroke-width=".055" paint-order="markers stroke fill"/><path d="M21.06 10.142c-.47 0-.923.103-1.256.286s-.52.432-.52.69c0 .54.795.976 1.776.976s1.776-.437 1.776-.976c0-.26-.187-.507-.52-.69s-.785-.286-1.256-.286z" fill="#fff" stroke-width=".05" paint-order="markers stroke fill"/></svg>
<label className="icolabl">9</label>
</object>

</div>
</div>
</div>
);
}
}


class Block extends React.Component {
render(){
return(
<div className="container-fluid">
<div className="row"></div>
<div className="col-lg" style={{textAlign: "justified"}}>
<h1>This is the 
<span style={{color: "orange"}}> left </span>
part. I want changes in the 
<span style={{color: "green"}}> right </span>
part only </h1>
</div>
<div className="col-lg">
<Right />
</div>
</div>
);
}
}
ReactDOM.render(
    <Block />, document.getElementById('content')
);
.ico {
 color: midnightblue;
    fill: mediumspringgreen;
    stroke: midnightblue;
    cursor: pointer;
    text-align: center;
}
.ico:hover{
fill: orange;
    color: orange;
    stroke: orange;
    
}
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.0/umd/react-dom.production.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="content"></div>
</body>
</html>

相关问题