我有三个div
-
一个是画布(完全响应并在调整窗口大小时自动调整大小)
-
是用SVG制作的垂直轴
-
是用SVG制作的水平轴
下面是我的代码的样子
var size = 300;
var canvas = new fabric.Canvas('g-canvas', {
selection: false,
backgroundColor: "#91653a",
});
canvas.setHeight(size);
canvas.setWidth(size);
$('#left-svg').attr({height:size});
$('#bottom-svg').attr({width:size + 57});
$('#svg-left-line').attr({y2:size});
$('#svg-bottom-line').attr({x2:size + 10});
ul,
li {
display: inline;
list-style: none;
margin: 2px;
}
ul {
text-align: center;
padding-left: 0px;
}
.toolMenu {
text-align: center;
}
#gSelect {
margin: 10px;
}
line{
fill: none;
stroke: black;
stroke-miterlimit: 10;
}
#left-canvas {
display: flex;
margin:10px;
}
#bottom-canvas {
height: 10px;
}
#bottom-canvas svg {
height: 10px;
}
#left-svg {
width: 10px;
margin-right: 5px;
}
#bottom-svg{
padding-left: 57px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.4.6/fabric.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col col-md-6 g-container-upper">
<div id="g-container" >
<div id="left-canvas" class="row justify-content-md-center">
<svg id="left-svg">
<g>
<line id="svg-left-line" x1="5" x2="5" y1="0"></line>
</g>
<g></g>
</svg>
<canvas id="g-canvas" style="border:1px solid #000000;"></canvas>
</div>
</div>
<div class="row">
<div id="bottom-canvas">
<svg id="bottom-svg" class="row justify-content-md-center">
<g>
<line id="svg-bottom-line" x1="0" y1="5" y2="5"></line>
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
在这段代码中,我试着把事情的总体思路放进去,但实际上我使用的是angular,我正在刷新很多dom元素,以使所有内容都具有良好的大小。现在我的问题是,我不知道如何把它作为一个整体来处理,例如,将它居中,并将所有的东西固定在一起。
由于我并不总是理解css的所有细微之处,我还得到了与子级不相同宽度的父div,而没有机会在DOM检查器中看到该特定大小的来源。
非常感谢您的帮助;)