How to get picture to align with the left set of paragraphs/go to right of?

烈酒焚心 提交于 2019-12-13 19:16:15

问题


Here is a prototype of what I am trying to implement

Here is what I currently have : JsFiddle

I am trying to get the picture of the guy on the laptop to align correctly with and to the right of the paragraph components - Business Traveller, Office Supply Purchases, etc...

What I've tried is using Align attribute, changing my img src code to

<img id="laptop" align="middle" src="zoom-39988392-3.JPG" height = "90" width ="90" />

but that didn't have any effect. I also tried Float but that messed up my margins and the organization of my left components.

Is there a way I can do this without floating?


回答1:


See the fiddle

The HTML and CSS that i've used is as follows. Used float:left

HTML

<div class="container">
    <div id="choices">
        <p class="choice">Business Traveller</p>
        <p class="choice">Office Supply Purchases</p>
        <p class="choice">Stay at home parent</p>
        <p class="choice">Entertainment</p>
        <p class="choice">Profile 6</p>
    </div>
    <div class="image"></div>
</div>

CSS

html, body, .container {
    height:100%;
}
#choices {
    width:30%;
    float:left;
}
.choice {
    margin-top:0px;
    margin-left:20px;
    text-align:center;
    width:100%;
    background-image: url("http://i.imgur.com/H43sVoi.png");
    padding-top:15px;
    padding-bottom:15px;
}
.image {
    height:100%;
    width:65%;
    background-color:red;
    float:left;
}

You will have to work with the height and width of each divs. I just made it roughly.




回答2:


You have to create two columns. 1 column for the menu and the second column for the image. If you do this, you wont have trouble floating.



来源:https://stackoverflow.com/questions/30093467/how-to-get-picture-to-align-with-the-left-set-of-paragraphs-go-to-right-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!