html - 使元素出现在 div 的右侧

标签 html css twitter-bootstrap

我正在制作这个小网站,我正在尝试制作用户资料。老实说,我不是最擅长 HTML 和 CSS 的人,但基本上,我的问题是,我想在“超大屏幕”的左上角显示个人资料图片(我正在使用 Bootstrap ),并将用户名放在在它的右边,在用户名下面有一小段/引用/格言。但是,我无法让它工作。

这是我当前的代码:

HTML

<div class="container">
    <!-- Profile Jumbotron-->
    <div class="jumbotron">
        <div class="profile-picture">

        </div>
        <h1><?php echo "$profile_name" ?></h1>
    </div>
</div>

CSS:

.jumbotron {
margin-top: 5%;
margin-bottom: 2%;
}

.profile-picture {
    width: 200px;
    height: 200px;
    background-color: white; /* Just as a test profile picture */
}

Here is the result of this code

我试图右对齐文本,但无济于事。

当然,还有明显的float:right,它工作得很好,但是the height of the jumbotron gets all screwed up!除非我做错了什么。

综上所述,我希望有人能帮助我,因为你在这里似乎很有帮助!

感谢您花时间阅读我的问题,希望您能帮助我解决问题!

最佳答案

<div class="container">
<!-- Profile Jumbotron-->
<div class="jumbotron col-md-12">
    <div class="profile-picture pull-left col-md-5">
        <img class="img img-responsive" src="Your image" style="width:200px"/>
    </div>
    <h1 class="pull-right col-md-7">
        <?php echo "$profile_name" ?>
    </h1>
</div>
</div>

.profile-picture {
    background-color: white; /* Just as a test profile picture */
}

我认为这样的事情可以解决问题,因为您使用的是 Bootstrap 框架。请注意我放置的 css 类 pull-leftpull-rightcol-md-5col-md-7 用于按列划分 div。

通过使用 img-responsive,您将能够在 div 内按比例对齐图像。

关于html - 使元素出现在 div 的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35786873/

相关文章:

html - 如何使用 css/jquery 在此代码中旋转六边形?

html - 导航栏品牌图像不适合导航栏高度

html - 如何只为列中的div设置背景颜色

javascript - 以下数据提交方式有哪些弊端?

javascript - 如何将此 jQuery 代码放入外部 .js 文件中?

javascript - Chrome 中凌乱的鼠标事件

javascript - 无法读取空 Bing map 的属性 'prototype'

html - 在 div 中定位可变数量的跨度

html - CSS 伪元素大小问题

javascript - Dropzone.js - 只显示完整上传的进度