How to get picture to align with the left set of p

2019-08-12 14:47发布

Here is a prototype of what I am trying to implement enter image description here

Here is what I currently have : JsFiddle enter image description here

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?

2条回答
小情绪 Triste *
2楼-- · 2019-08-12 14:59

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.

查看更多
干净又极端
3楼-- · 2019-08-12 15:03

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.

查看更多
登录 后发表回答