简体   繁体   English

div位于上一个

[英]Div positioned under previous

I am simply trying to get all the text on this page to appear to the right of the picture. 我只是想让此页面上的所有文本都显示在图片的右侧。 Everything is pushed below. 一切都被推到下面。 Tried adding float: left to both image and text but they just come out of their container instead and are in the same position. 尝试添加float:同时保留图像和文本,但它们只是从容器中出来,并且位于同一位置。

Link to the live Demo 链接到现场演示

CSS 的CSS

.full-bio-container {
    padding: 10px;
    background-color: #fff;
    margin-top: 40px;
}

#full-bio-chef-pic {
    display: inline-block;
    position: relative;
    left: 0;
    vertical-align: top;
}

.full-bio-info {
    display: inline-block;
    position: relative;
    left: 0;
    width: auto;
    height: auto;
    padding: 0px 10px 10px 10px;
    vertical-align: top;
}

HTML 的HTML

<!-- Start Chef Bio -->
<div class="full-bio-container">
    <div id="full-bio-chef-pic">
        <img src="img/about/head-chef.jpg" alt="" title="" height="300" width="200" />
    </div>
    <div class="full-bio-info">
        <h4>Head Chef - Ed</h4>
        <p class="full-bio-caption">“Ed admiring the sample plates kindly supplied by Churchill’s, a strange love affair in ongoing with these plates. Thank You to Churchill’s for their amazing support"</p>
        <p>As soon as he was tall enough to reach the kitchen work-tops Ed would be found helping in the kitchen.  One of his mother’s earliest memories was seeing him standing on a chair naked except for an apron adding toppings to pizza bases!</p>
        <p>Over the years his passion for cooking had developed and his skills improved. After leaving school proudly clutching the Food Technology prize he went onto to study at Westminster Kingsway college London where he obtained the Professional Chef qualification. During his time at Westminster he won several competitions including National Young Chef of the year from this prestigious college.</p>
        <p>After leaving college Ed’s experience has ranged from fine dinning in London’s top restaurants to village gastro pubs, along with a wide variety of other experiences from private dinning and chalet chef to some of the UK’s top celebrities.</p>
        <p>It was as result of a conversation with one of his clients that The Naked radish was born. His is aim to share his passion for food and help you fall in love with cooking again by taking the drudgery away and creating inspiring, healthy recipe kits and sharing chef’s tips which often stay secret in the kitchen.</p>
    </div>
</div>
<!-- End Chef Bio -->

Try to change these on css. 尝试在CSS上更改这些。 What I changed, I made the content more narrow. 我进行了更改,使内容范围更加狭窄。 And floated both containers, img to left and content to right. 然后浮动两个容器,将img放到左边,将内容放到右边。

#full-bio-chef-pic {
display: inline-block;
position: relative;
left: 0;
vertical-align: top;
float: left;
}

.full-bio-info {
display: inline-block;
position: relative;
left: 0;
width: auto;
float: right;
width: 700px;
height: auto;
padding: 0px 10px 10px 10px;
vertical-align: top;
}

If you want to float elements they need a fixed width. 如果要浮动元素,则需要固定宽度。 Give .full-bio-info a width of 695px(for example) and it will work. 给.full-bio-info一个695px的宽度(例如),它将起作用。

Or is there a special reason for that width: auto; 还是该宽度有一个特殊原因:自动; ?

If you want dynamic width you should use "img/about/head-chef.jpg" as a Backglound-image of .full-bio-info and give .full-bio-info a padding (left) of 200px(or more) too. 如果您想要动态宽度,则应使用“ img / about / head-chef.jpg”作为.full-bio-info的背景图像,并为.full-bio-info填充200px(或更高)的填充量(左)太。

Use the following CSS. 使用以下CSS。 What I changed is float: left; 我更改的是float:left; on the full-bio-chef-pic and removed display: inline-block on full-bio-info. 在完整的生物厨师图片和已删除的显示器上:在完整的生物信息上内联阻止。

#full-bio-chef-pic {
    display: inline-block;
    float: left;
    position: relative;
    left: 0;
    vertical-align: top;
}

.full-bio-info {
    position: relative;
    left: 0;
    width: auto;
    height: auto;
    padding: 0px 10px 10px 10px;
    vertical-align: top;
}

I hope this works. 我希望这行得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM