php - 将元素置于另一个元素的右侧

标签 php css

我在照片上传裁剪工具中有两个元素,我试图将它们并排放置在中间。

    .imageuploadcropcontainer {
    	text-align:center;
    	margin: 0 auto;
    }
<div class="imageuploadcropcontainer">
        <img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" style="margin-right: 10px;" id="thumbnail" alt="Create Thumbnail" />
        <div style="border:1px #e5e5e5 solid; position:relative; overflow:hidden; width:<?php echo $thumb_width;?>px; height:<?php echo $thumb_height;?>px;">
            <img src="<?php echo $upload_path.$large_image_name.$_SESSION['user_file_ext'];?>" style="position: relative;" alt="Thumbnail Preview" />
        </div>

带有 alt="Create Thumbnail"的图像源已经在中心,但图像源 alt="Thumbnail Preview"位于页面的左侧。如果我将此元素放在右侧 float ,那么它会移动到页面的最右侧页面,我不想使用边距来设置它,否则就可以了。

最佳答案

.imageuploadcropcontainer {
    margin: 0 auto;
    width: 300px;
}

.imageuploadcropcontainer #thumbnail,
.imageuploadcropcontainer .hello {
    width: 50%;
    float: left;
}

.imageuploadcropcontainer:after {
  content: '';
  display: block;
  clear: both;
}
<div class="imageuploadcropcontainer">
    <img src="" id="thumbnail" alt="Create Thumbnail" />
    <div class="hello" >
        <img src="#" alt="Thumbnail Preview" />
    </div>

评论问题后更新:

can i manipulate the space between the two

当然可以,这取决于您的确切需求。现在两者之间没有空间。运行下一个代码段时查看绿色边框。

.imageuploadcropcontainer {
    margin: 0 auto;
    width: 300px;
    border: solid 1px orange;
}

.imageuploadcropcontainer #thumbnail,
.imageuploadcropcontainer .hello {
    width: calc(50% - 2px);  /* 2px is border 1px left + 1px right from each box */
    float: left;
    border: solid 1px green;
}

.imageuploadcropcontainer:after {
  content: '';
  display: block;
  clear: both;
}
<div class="imageuploadcropcontainer">
    <img src="" id="thumbnail" alt="Create Thumbnail" />
    <div class="hello" >
        <img src="#" alt="Thumbnail Preview" />
    </div>

关于php - 将元素置于另一个元素的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42019181/

相关文章:

php - Laravel Eloquent 的条件 wherehas

html - 网格属性不适用于网格容器内的元素

javascript - 滚动时动画不起作用 - JQuery

javascript - 如何使用 vue 将类别 ID 传递给产品列表?

php - MySQL如何实现层级数据的级联删除?

javascript - 如何使用javascript在选中复选框时激活按钮?

jquery - 播放动画时去除边框

jquery - 尝试将图像放入我的日期选择器输入中

php - 如何访问 Laravel 中某些特定 Controller 的数据?

javascript - 如何根据选择框显示输入并删除它?