Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

I'm sure it's simple but...

neza

New Coder
Hello,
I am still learning. Why can't I just make the second half look like the first one, but with picture on the right and text a little over it? Thank you for your help!!!

Here is the code:

HTML:
HTML:
<div class="opis1">
    <div class="opis1slika">
   </div>
    <div class="opis1tekst">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    </div>
  </div>

  <div class="opis2">
    <div class="opis2tekst">
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
    </div>
    <div class="opis2slika">
   </div>
  </div>

CSS:
CSS:
.opis1 {
    display: inline-block;
    width: 100%;
    background-color: #ccecf4;
}

.opis1slika {
    display: inline-block;
    float: left;
    background-color: #ccc;
    width: 600px;
    height: 400px;
}

.opis1tekst {
    width: 60vw;
    display: inline-block;
    margin-top: 20px;
    margin-left: -40px;
    background-color: rgba(255, 255, 255, 0.3);
}

.opis1tekst p{
    font-size: 20px;
    padding: 60px;
}

.opis2 {
    display: inline-block;
    width: 100%;
    background-color: #ece5d9;
}

.opis2slika {
    display: inline-block;
    float: right;
 
Last edited by a moderator:
Two tips that might help to get a solution :
  • Post code in proper code tags, using the </> button in the toolbar
  • Post complete HTML/CSS/JS so that someone can cut and paste it to try it out
 
Noticed two things about your code right away. You never completed CSS for the second area and you love display: inline-block; even though it's not needed for anything in your code. Go and read about it and all the display modes.

You have two divs, one to hold the text and one to hold the image inside of a larger div. By the way, I use one of my images, you can just change the src to the ones you want. I commented everything in the CSS out except for the opis divs. I did remove all display: inline-block; from everywhere so I won't say that again. I added padding cause we should. These are the first two CSS rules.

Next came the tekst. Very minimal. Both are in one rule.

Lastly, I floated the contents of the bottom div to the right. Don't forget to clear the float.
I did place the height and width of the image in the img tag and not css just a preferential matter.

You should notice the text and image are not of the same width and therefore funny looking. Fix that.

Good Luck on your progamming journey.
The Old Man
Code:
<style>
.opis1, .opis2  {
    width: 100%;
    padding: 20px;
    background-color: #ccecf4;
}
.opis2 {
    background-color: #ece5d9;
}
.opis1tekst, .opis2tekst{
    width: 60vw;
    background-color: rgba(255, 255, 255, 0.3);
}
.opis1tekst p, .opis2tekst p{
    font-size: 20px;
    padding: 60px;
}
.opis2slika, .opis2tekst {
    float:right;
}
</style>
</head>
<body>
<div class="opis1">
    <div class="opis1tekst">
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
            do eiusmod tempor incididunt ut labore et dolore magna
            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
            ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </p>
    </div>
    <div class="opis1slika"><img src="fish.jpg" alt="" width="600" height="400"></div>
</div>
<div class="opis2">
    <div class="opis2tekst">
        <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
            do eiusmod tempor incididunt ut labore et dolore magna
            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
            ullamco laboris nisi ut aliquip ex ea commodo consequat.
        </p>
    </div>
    <div class="opis2slika"><img src="fish.jpg" alt="" width="600" height="400"></div>
</div>
</body>
</html>
 

New Threads

Buy us a coffee!

Back
Top Bottom