Creating a rectangle with text inside a pattern [closed] - html

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am new in HTML and CSS and there is a problem I am facing using CSS.
I want to create a section like this:
---Picture---
--Text--
---Picture---
--Text--
---Picture---
--Text--
---Picture---
--Text--
I want the text to be wrapped inside a rectangle with a specific background color. The issue is that whenever I am setting a background-color for my rectangle, the size of the div includes all of the content beneath.
.lower-part {
margin-top: 15%;
}
.lower-part .row .image img {
height: 80%;
width: 80%;
}
.lower-part .row .textbox {
background-color: red;
}
<div class="lower-part">
<div class="row">
<div class="image"><img src="images/BadmintonPicture.svg" alt="Badminton Picture"></div>
<div class="textbox1">
Sports.
<p>For me, nothing is better than regular excercise. It keeps me energetic throughout the day.</p>
<div class="row">
<div class="image"><img src="images/CookingPicture.svg" alt="Cooking Picture"></div>
<div class="textbox">
Cooking.
<p>I LOVE Food. I try to experiment with new recipes whenever I can. The Food Lab by Kenji Lopéz-Alt helps me being a better cook.</p>
<div class="row">
<div class="image"><img src="images/ReadingPicture.svg" alt="Reading Picture"></div>
<div class="textbox">
Reading.
<p> I love self-development books, because it helps me grow as a person.
<span>Favourites:</span>
<br>Slight Edge, Atomic Habits, How to Win Friends & Influence People .
</p>
<div class="row">
<div class="image"><img src="images/GuitarPicture.svg" alt="Guitar Picture"></div>
<div class="textbox">
Music.
<p>I grew up playing the violin but the guitar seemed way cooler. So I stick with that for the most part. Also, I like to sing every few minutes.</p>
</div>
</div>
</div>
Sass
.lower-part {
margin-top: 15%;
.row {
.image {
img {
height: 80%;
width: 80%;
}
}
.textbox {
background-color: red;
}
}
}

You forgot to close your <div> tags.
It helps if you properly indent and use new lines for new tags, because this way you can easily keep track of open tags.
<div class="lower-part">
<div class="row">
<div class="image">
<img src="images/BadmintonPicture.svg" alt="Badminton Picture">
</div>
<div class="textbox1">
Sports.
<p>
For me, nothing is better than regular excercise.
It keeps me energetic throughout the day.
</p>
</div>
</div>
</div>
etc.

Related

Three inline div height responsiveness is not working on Firefox [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
On my website I have 3 responsive divs inline, that remain all the same size. I developed it on a 15" MacBook Pro & it works perfectly on Safari, Chrome & Firefox (on Mac). See image below:
But I'm building it for my friend and he keeps telling saying that when he goes to the website on his Microsoft computer the divs wont maintain the same height and look like the following:
I've tried so many different things and especially because I cannot replicate the problem on my MacBook, I'm finding it really hard to root out the problem. What is going wrong here?
.flexbox {
display: flex;
}
.trip {
background-color: white;
margin-bottom: 10px;
padding-bottom: 5px;
max-height: 230px;
overflow-x: scroll;
white-space: nowrap;
}
<div class="container flexbox" style="width:100%; background-color:#205ba0; padding:30px;">
<div class="col-md-offset-3 col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/rent.png" style="height:100px;">
</div>
<h2 style="font-weight:bold;">Renting? Landlords welcome.</h2>
A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.<br><br>
Find out more >
</div>
<div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/val.png" style="height:100px;">
</div>
<h2 style="font-weight:bold;">Valuation? Sorted quickly.</h2>
Providing some of the most effecient valuations in town, we're here to help you sort out an important step.<br><br>
Find out more >
</div>
<div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/sale.png" style="height:100px;">
</div>
<h2 style="font-weight:bold;">Selling? Now uncomplicated.</h2>
We aim to make selling easy. Our trained estate agents are constantly available to help.<br><br>
Find out more >
</div>
</div>
o.k - because it is hard to point out your exact problem due to reasons like a change in the runtime environment & a mix of html and css styling while using bootstrap I took the liberty of cleaning your code & making use of the bootstrap grid system ...
iv'e added some elements , removed the flexbox & moved all of your styling to css to make it easier for you to see the separation and for others to help you ...
the result is pretty much the same except that i changed the number of columns that each "box" occupies due to the text flowing out of the div when the boxes take up 3 columns (BTW this also occurred with your previous code on smaller screens) so I encapsulated half of the heading (the statements after the question mark) in smaller heading tags (<h5>) and now it changes the size before it has a chance to overflow ...
now you can keep playing around with the grid system until you reach the desired result ...
HTML:
<div id="maincontainer" class="container-fluid row">
<div id="box1" class="col-md-4 col-sm-4 col-xs-4">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/rent.png" alt="">
</div>
<h3>Renting? <h5>Landlords welcome.</h5></h3>
<p>A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.</p>
<br><br>
Find out more >
</div>
<div id="box2" class="col-md-4 col-sm-4 col-xs-4">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/val.png" alt="">
</div>
<h3>Valuation? <h5>Sorted quickly.</h5></h3>
<p>Providing some of the most effecient valuations in town, we're here to help you sort out an important step.</p><br><br>
Find out more >
</div>
<div id="box3" class="col-md-4 col-sm-4 col-xs-4">
<div class="trip">
<img src="http://localhost/property_abba/wp-content/uploads/2017/05/sale.png" alt="">
</div>
<h3>Selling? <h5>Now uncomplicated.</h5></h3>
<p>We aim to make selling easy. Our trained estate agents are constantly available to help.</p><br><br>
Find out more >
</div>
</div>
CSS:
h2{
font-weight:bold;
}
a{
color:white;
}
img{
height:100px;
}
.trip {
background-color: white;
margin-bottom: 10px;
padding-bottom: 5px;
max-height: 230px;
}
#maincontainer{
background-color:#205ba0;
padding:30px;
text-align:center;
}
#box1 , #box2 , #box3{
color:white;
border:2px solid white;
font-size:12px;
padding:10px;
}
CodePen

Height Auto Not Working

I am using bootstrap and basic CSS on my app and for some reason the height-auto on a div isn't working. The height is shown as 0 even though there is text in the div. Here's my html:
<div class="container">
<div class="outlined-div">
<h2 class="text-center col-xs-12" style="color: red">Men are not born knowing how to barbecue.</h2>
<div class="col-xs-12 col-sm-6">
<h4>Good luck explaining this to your buddies.</h4>
<h4>All men are capable. Few are properly trained.</h4>
<h4>Instead, we undergo years of trial and error, suffering through snide comments from our buddies and smug looks from our fathers-in-law. This ends now.</h4>
</div>
<div class="col-xs-12 col-sm-6">
<h4>While men don’t ask for directions (see the man code), it’s only right that we share hints, hacks, and other help with our fellow brothers.</h4>
<h4>Give them a leg up in impressing others with our stellar barbecuemanship.</h4>
<h2 style="color: red">Grill on, brothers.</h2>
</div>
</div> <!-- outlined-div -->
</div> <!-- container -->
Here's my css for outlined-div:
.outlined-div {
background-color: white;
border: solid medium red;
border-radius: 5px;
padding-left: 15px;
padding-right: 15px;
height: auto !important;
}
And here's how it's showing up:
If I put in a fixed height (e.g. height: 10px) the red line expands into a box 10px high.
Can anyone see where I'm going wrong here?
Add the class clearfix to your outlined-div
This will clear the floats added by Bootstrap to create the column layout.
To learn more about clearfixes, read this question: What is a clearfix?

Height of heading element is more than expected [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I've got this html here:
#books {
margin-top: 4rem;
}
<div class="row">
<div class="col-lg-10 col-lg-offset-1 well">
<h1 class="text-center">Brian Jacques</h1>
<h3 class="text-center"><i>The scribe who was an abbot to all his readers</i></h3>
<figure class="figure col-lg-12">
<div class="img-thumbnail col-lg-10 col-lg-offset-1">
<img src="http://i1378.photobucket.com/albums/ah88/ejacobosaur/Brian%20Jacques%20Cartoonized_zpsz412eynr.jpg" class="img-responsive figure-img img-fluid" alt="Brian Jacques cartoon">
<figcaption class="figure-caption text-center">Jacques smiling. A radiance that shines through his books. Painted by Derek Wehrwein. </figcaption>
</div>
</figure>
<h2 class="text-center" id="books">Widely Known For
</h2>
<div class="row">
<div class="col-lg-6 text-center">
Redwall
</div>
<div class="col-lg-6 text-center">
Castaways of the Flying Dutchman
</div>
</div>
<blockquote>
<p class="text-center lead"><em>"So here is my story, may it bring<br>Some smiles and a tear or so,<br>It happened once upon a time,<br>Far away, and long ago,<br>Outside the night wind keens and wails,<br>Come listen to me, the Teller of Tales!"</em></p>
<footer class="text-center">Brian Jacques,<cite title="Lord Brocktree"> Lord Brocktree</cite></footer>
</blockquote>
</div>
</div>
The part concerning my question is the h2 tag that is directly under the closing figure tag and has the text "Widely Know For".
I've been trying to add top margin to this element (h2) but have had no success. When I opened it up in debugger mode and select this element, it shows that its height extends almost to the top of the page instead of to the bottom of the element above it (figure).
Just to see, I took out this h2 element so that the div under it took its place. This div did not have the same problem. It had a normal height and I was able to add a top margin to it just fine.
It seems to be just the heading tag that has this problem.
I'm thinking the issue has to do with the html in some way but I have no idea why.
Here's the link to the codepen:http://codepen.io/edsonmendieta/pen/jqjRry
Help is greatly appreciated, thank you.
The problem is that you're following a floated element. You'll need to apply one technique or another to clear the float. See here.
The simplest option is probably to use Bootstrap's built-in clearing class:
<div class="clearfix"></div>
<h2 class="text-center" id="books">Widely Known For</h2>
The bootstrap class .col-lg-12 which the figure above your h2 has, has float: left;. Floated elements are not calculated into the parent element 's height.
Remove that class from the figure element - this will fix it and let you change the top margin and distance of your h2 element.
http://codepen.io/anon/pen/WwVdPO

HTML and CSS rectangle not displaying correctly

Hello I have a site where there is some text telling the user about the site. I want to draw a white rectangle behind the text to separate it from the background.
I am able to draw the rectangle, but the rectangle draws over the text.
I am using the below CSS code to draw the rectangle:
#rect1 {
position: absolute;
width: 100px;
height: 100px;
background: #ffffff;
}
Here is the HTML in the main page:
<body>
<div class="container_24">
<header>
<h1>Omicrome</h1>
<nav>
<ul>
<li><a href="# " class=s elected>Home</a></li>
<li>Articles</li>
<li><a href="software.html">Projects</a ></li>
<li>About</li>
</ul>
</nav>
<div class="banner grid_18" href="about.html">
View Article
<h2>
</h2>
</div>
<div class=" grid_8 callout"></div>
View Gallery
</header>
<div id="rect1"></div>
<div class="main clearfix">
<div class="grid_9">
<h3>About The Site</h3>
<p>Here at Omicrome we are always coming up with new and innovative ideas for the future and for the present. These ideas are researched and expanded upon to make them a reality. View our ideas in the article section and see them come to life in
the project section. Our many project's range from software to hardware, Huge build's to small and fun one day project's. We are all about space and technology...
<p>Find Out More</p>
</div>
<div class="grid_9">
<h3>Our Content</h3>
<p>We post a variety of ideas and project's based around space and technology. Some of them include a hand held cheap computer, software to teach people about space and snapshot's of stellar and interstellar objects visible from our telescope. We
ask questions like "Why dont we have a robotic Mars colony?" and find an answer or solution. </p>
<p>
</p>
<p> </p>
<p>Find Out More</p>
</div>
<div class="grid_6">
</div>
The
<div id "rect1></div>
is the part that says draw a rectangle in the html code. How can I get it to draw the rectangle behind the text?
You can add
z-index: -1;
to the #rect1:
#rect1{
position: absolute;
width: 100px;
height: 100px;
background: #ffffff;
z-index: -1;
}
Fiddle
(You should probably also adjust the rectangle size to make it look better.)
If you really want to use absolute position, set its z-index to -1.
But I think you might just want to give the div or span that contains the text a different background and border instead of drawing a new div behind it.
<html>
<head>
<style>
#rect1{
position: absolute;
width: 100px;
height: 100px;
background: #eee;
z-index:-1;
}
</style>
</head>
<body>
<div class = "container_24">
<header>
<h1>Omicrome</h1>
<nav>
<ul>
<li><a href="# " class = selected>Home</a></li>
<li>Articles</li>
<li><a href="software.html">Projects</a ></li>
<li>About</li>
</ul>
</nav>
<div class = "banner grid_18" href="about.html">
View Article
<h2>
</h2>
</div>
<div class=" grid_8 callout"></div>
View Gallery
</header>
<div id = "rect1"></div>
<div class = "main clearfix">
<div class ="grid_9">
<h3>About The Site</h3>
<p>Here at Omicrome we are always coming up with new and innovative ideas for the future and for the present. These ideas are researched and expanded upon to make them a reality. View our ideas in the article section and see them come to life in the project section. Our many project's range from software to hardware, Huge build's to small and fun one day project's. We are all about space and technology...
<p>Find Out More</p>
</div>
<div class ="grid_9">
<h3>Our Content</h3>
<p>We post a variety of ideas and project's based around space and technology. Some of them include a hand held cheap computer, software to teach people about space and snapshot's of stellar and interstellar objects visible from our telescope. We ask questions like "Why dont we have a robotic Mars colony?" and find an answer or solution. </p><p>
</p><p> </p>
<p>Find Out More</p>
</div>
<div class ="grid_6">
</div>
</html>
Thats your code.. Moreover you can use bootstrap classes like well to separate your div text from the other content if you wish to.
I kept the background-color to be #eee so that you can see it. Edit it according to your need.

Centering a border that is smaller than its div [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have two divs that are col-xs-12 wide. There is no margin between them so they touch. I would like to add a border between them, like the image on the right (what I have currently is on the left).
I tried adding a 1 px height 11-wide column and centering it, but of course you can see a gap between the two rows on each side of the border.
Here's a jfiddle of the whole thing.
<div class="row top-buffer-10">
<div class="col-xs-12">
<div class="header-text">
<p style="font-size:130%"><b>%REGION%</b></p>
<p style="padding-bottom:15px;">(currently selected)</p>
</div>
</div>
</div>
<div class="row top-buffer-10">
<div class="col-xs-12">
<div class="img-with-text">
<img style="margin-top:5px;" src="img/gsd_list_contact.png" alt="itscl" />
<p style="font-size:90%;padding-left:0px;"><b>PHONE:</b> %LOCAL_PHONE%<br>
<b>TOLL FREE:</b> %TOLL_FREE%<br>
<b>LANGUAGE:</b> %LANGUAGE%
</p>
</div>
</div>
</div>
These are the two relevant divs to look out for.
There seems to be a little confusion, I want the border to be small than the div, as in, not just adding border top or border bottom.
See how the border doesn't quite reach the edges of the div. Thanks.
Here is a possible solution: https://jsfiddle.net/yjtrk00o/4/
EDIT:
add a css called division as shown below
In your HTML, add the line <hr class="division"/> just above the <div class="img-with-text">
CSS
.division{
border-top:1px solid #D3D3D3;
margin-top:0px;
margin-bottom:0px;
margin-left:10px;
margin-right:10px;
}
HTML
<div class="col-xs-12">
<hr class="division"/>
<div class="img-with-text">
I'm not sure if it's the desired effect you're after, but have you tried the following:
<div class="img-with-text" style="border-top: 1px solid black;">
Obviously you can fiddle with colour etc, or add that into the css class.
EDIT:
perhaps this then:
<div class="col-xs-12">
<div style="margin: 0 10px; display: block; height: 1px; background: #000;"></div>
<div class="img-with-text">
You can play with the margin to give you the offset from the edges you want. Probably not the most elegant solution, but seems to get the visual result you're after?