I realize there is another thread that addresses this issue, but I'm having trouble implementing some of the suggestions to my particular situation. As of now I'm kind of experimenting but would appreciate any suggestions. Here is a screenshot of the portrait that I want cropped in a circle: http://imgur.com/autCwaj
Although I may be way off course, my code is as follows--
The HTML:
<section class="hero">
<div class="content">
<div class="image-cropper">
<img class="my-picture" src="http://imageweb-cdn.magnoliasoft.net/bridgeman/supersize/xir245162.jpg" alt="This is a picture of me">
</div>
<p class="iama">My name is...</p>
<p class="my-name my-info">Jason Brain</p>
<p class="iama">I want to be (eventually)...</p>
<p class="my-info">A front end, full stack, and iOS developer</p>
</div>
</section>
The CSS:
.image-cropper {
width: 100px;
height: 100px;
position: relative;
}
.my-picture {
display: block;
margin: 0 auto;
height: 100%;
width: auto;
border: 2px solid white;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
Thanks for your assistance everyone.
If you want a circle instead of an oval, you'll need to rearrange some CSS. The outer div needs to be square and the image needs to stretch the small of its two dimensions to 100% of the otter div.
.image-cropper {
width: 100px;
height: 100px;
position: relative;
border: 2px solid white;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
overflow:hidden;
}
.my-picture {
display: block;
margin: 0 auto;
height: auto;
width: 100%;
}
<section class="hero">
<div class="content">
<div class="image-cropper">
<img class="my-picture" src="http://imageweb-cdn.magnoliasoft.net/bridgeman/supersize/xir245162.jpg" alt="This is a picture of me"/>
</div>
<p class="iama">My name is...</p>
<p class="my-name my-info">Jason Brain</p>
<p class="iama">I want to be (eventually)...</p>
<p class="my-info">A front end, full stack, and iOS developer</p>
</div>
</section>
Related
I have a problem with the size of the cards. On the Desktop side are ok, but on a lower resolution begin to be no longer equal. How should I proceed in this situation? I'm not an expert in css, I work on the backend but I would like in the future to have a correct solution how I could solve something like.
html
<div class="proditem">
%PROMO%
<div class="proditem_cover">
%COVER%
%promo_period%
</div>
<h3 class="protitem_title">
%TITLE%
</h3>
<div class="protitem_price">
%PRICE% eur %price_euro%
</div>
<div class="detalils"><a class="button1" href="%LINK%">Details</a></div>
</div>
a {
text-decoration: none;
color: inherit;
font-size:16px;}
.list_prod .proditem {
height: auto;
max-height: initial;
float: none;
display: inline-block;
margin-bottom: 10px;
vertical-align: top;
transition: 0.3s;
width: 40%;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
padding: 2px 16px;
border: 0 !important;
border-radius: 1rem;
.proditem img {
width: 170px;
height: 170px;
max-width: 10vw;
max-height: 10vw;
/* object-fit: cover; */
}
image
As far as I can see, they decrease in size because they don't have the same information, depending on the text and image if they're not equal. How can I make them equal regardless of the information they have?
Maybe you can try to create wrapper class like :
<div style="width:100%; height:auto; display:flex; justify-content:flex-start;" class="wrapper">
<div style="width:50%; height:100%; " class="content"> <div/>
<div style="width:50%; height:100%; class="content"> <div/>
<div/>
This just a simple example to give you a some styling or aligning tricks. Try and write me if its not-proper code for you.
This question already has answers here:
CSS-only masonry layout
(4 answers)
Closed 2 years ago.
I have 4 divs that lay two in row and two columns. They are different height and I want it to be taken into consideration when displaying on page. I always want the lower divs to stick vertically to upper ones like in the left side.
Now the code.
app.component.html
<div id="wrapper">
<div id="content">
<div id="first-row">
<div class="col">
<br>
<a routerLink="/projects/endless-blow">Endelss Blow</a>
<br>
<a routerLink="/projects/endless-blow"><img src="assets/images/endlessblow_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="https://freeiconshop.com/wp-content/uploads/edd/android-flat.png" width="75px" height="75px">
<img src="https://cdn.iconscout.com/icon/free/png-256/java-23-225999.png">
<img src="https://inforce.rs/wp-content/uploads/2018/07/spring-boot-logo-e1530901263416.png" width="188px" height="75px">
<img src="assets/images/postgresql_icon.png" width="75px" height="75px">
</div>
</div>
<div class="col">
<br>
<a routerLink="/projects/book-library">Book Library API</a>
<br>
<a routerLink="/projects/book-library"><img src="assets/images/win_console_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/java_icon.png">
<img src="assets/images/jetty_icon.png" width="265px" height="75px">
</div>
</div>
</div>
<div id="second-row">
<div class="col">
<br>
<a routerLink="/projects/endless-blow">Endelss Blow</a>
<br>
<a routerLink="/projects/endless-blow"><img src="assets/images/endlessblow_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/android_icon.png" width="75px" height="75px">
<img src="assets/images/java_icon.png">
<img src="assets/images/spring_boot_icon.png" width="188px" height="75px">
<img src="assets/images/postgresql_icon.png" width="75px" height="75px">
</div>
</div>
<div class="col">
<br>
<a routerLink="/projects/book-library">Book Library API</a>
<br>
<a routerLink="/projects/book-library"><img src="assets/images/win_console_icon.png"></a>
<br><br>
<hr>
<br>
<div class="technology_images">
<img src="assets/images/java_icon.png">
<img src="assets/images/jetty_icon.png" width="265px" height="75px">
</div>
</div>
</div>
</div>
</div>
app.component.css
html, body {
margin: 0;
padding: 0;
align-items: center;
text-align: center;
}
body {
border: 3px solid green;
max-width: 600px;
margin: 0 auto;
color: #fff;
}
#wrapper {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
background: darkcyan;
}
#content {
border: 3px solid red;
box-sizing: border-box;
position: absolute;
padding: 0;
margin-left: 0;
margin-right: 0;
text-align: center;
overflow: auto;
left: 0;
right: 0;
top: 70px;
width: 100%;
}
#content a {
font-size: 25px;
}
#first-row {
margin-top: 20px;
}
.col {
border-radius: 15px;
-moz-border-radius: 15px;
display: inline-block;
width: 350px;
min-height: 350px;
border: 3px solid green;
background: rgba(150, 150, 50, 0.8);
vertical-align: top;
text-align:center;
margin: 0 40px;
/* margin-right: 100px; */
}
.col a img {
padding:0;
left:0;
right:0;
margin: 0 auto;
}
.technology_images {
text-align: left;
}
div:not(.technology_images, .col) {
min-height: 400px;
box-sizing: border-box;
width: 100%;
}
If you need code uploaded with result just take a look here
I did not see any topic that corresponds to my problem so please do not close this topic.
Thank you! :)
This is really hard to achieve with HTML/CSS, and be flexible at the same time, nearly to impossible I would say, because in the real world, you might not know what height and width your elements really are and how many there are on each column.
The only HTML/CSS solution (if this fits your case) would be to create a single row, with multiple columns in it and display all the items by column. For this one, you really need to know beforehand exactly how many elements you would have on each column.
For a flexible solutions, I would really recommend using Masonry. This library would help you achieve the result you need really fast without having to do a complicated layout, which will also be complicated to maintain in the long run when multiple items might get added.
My CSS:
#container {
position: center;
margin-top: 80px;
z-index: 950;
{block:IfGridTheme}margin-left: 430px;{/block:IfGridTheme}
{block:IfNotGridTheme}margin-left: 435px;{/block:IfNotGridTheme}
}
.entry {
position: justify;
font-size: 12px;
color: {color:Body Text};
font-family: roboto condensed;
letter-spacing: 1px;
{block:PermalinkPage}width: 1000px;
margin-top: 15px;{/block:PermalinkPage}
word-wrap: break-word;
margin-top: 45px;
}
#container1 {
white-space: nowrap;
border: none;
width: 100%;
margin-left: auto;
margin-right: auto;
}
#container1 > div {
background: none;
width: 100%;
height: 100%;
display: inline-block;
padding: 1% 5%;
margin-right: 176px;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
and my HTML for a certain type of page:
<div id="container1">
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="LINKTOFIRSTIMAGE" height="575" src="LINKTOFIRSTIMAGE" />
<div class="captioning">
<div class="caption"><em>CAPTION</em></div>
</div>
</div>
</div>
</div>
<div>
<div class="picture_holder" style="width: 1080px;">
<div class="picture" style="width: 1080px;"><img alt="SECONDIMAGELINKANDSOFORTH" height="575" src="SECONDIMAGELINKANDSOFORTH" />
<div class="captioning">
<div class="caption"></div>
</div>
</div>
</div>
</div>
</div>
On a given page with a sequence of images that are exactly the same height, width, and overall aspect ratio, the spacing between them is exactly the same (though a lot wider than I would like) like in 1) of this drawing:
... but in a sequence of images that have the same height but wildly varying widths, the spacing is pretty off like in 2).
I personally don't want either. How do I change my code so that, for both these types of pages and however many more pages I plan to create, that the spacing between every image is exactly the same amount of pixels across the whole board of the site? Is there an imaginary box around these images causing the issue?
edit: I should also state that I am using the HTML function on a website, Tumblr.com, so certain properties like flex never seem available.
edit2: display: grid; and similar don't appear available either. This is also at the top of the code if that helps:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Thank you for the info so far.
Your html structure:
<div id="parent_container">
<div id="card_1" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:red">
<caption>Card 1 caption</caption>
</div>
<div id="card_2" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:violet">
<caption>Card 2 caption</caption>
</div>
<div id="card_3" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:seagreen">
<caption>Card 3 caption</caption>
</div>
<div id="card_4" class="card_properties">
<h3>Title to image 1</h3>
<img style="background:skyblue">
<caption>Card 4 caption</caption>
</div>
</div>
Your CSS structure:
#parent_container <=== setting up flex for container
{
display: flex;
flex-wrap: wrap; <=== makes sure if the cards are many then they go on next line
justify-content: space-evenly; <=== makes sure there is equal space
}
.card_properties
{
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
border-radius: 14px;
width:20vw;
height:200px;
padding:1em;
}
img <=== written this additional because I didn't have time to find image
{
width: 100%;
height: 120px;
border-radius: 14px
}
Working codepen example
I'm having a tough time keeping my content centered within a certain width on my personal website. I have tried many methods such as setting body to a fix width and my wrapper container to a percentage of that. I have attached a picture of my website here and highlighted where I want my content to be contained in the picture shown
.
I want my content of my website centered within that highlighted area, while at the same time keeping the background to be the full size of the screen.
I realize this may be a simple question for many, but I have spent all day looking for and trying out different methods to do this with no avail.
body {
background-color: #F0f0f0;
text-align: center;
margin-right: 0px;
margin-left: 0px;
}
.wrapper {
text-align: center;
}
.topSection {
height: 300px;
border: solid 5px;
}
.mainAbout {
padding-left: 50px;
padding-right: 50px;
vertical-align: middle;
}
.mainAbout h1 {
font-size: 60px;
font-family: arvo, sans-serif;
margin-bottom: 5px;
}
#leftBrace {
vertical-align: middle;
}
#rightBrace {
vertical-align: middle;
}
.projects {
height: 864px;
border: solid 5px;
margin-top: 2px;
background: #0F1217;
}
.projects h2 {
color: #e6e6e6;
font-family: arvo, sans-serif;
font-size: 50px;
}
<link href="https://fonts.googleapis.com/css?family=Arvo" rel="stylesheet">
<div class="wrapper">
<!---- Wrapper Starts Here --->
<div class="topSection" style="display:block" ;>
<!---- Name Section Starts Here --->
<div id="leftBrace" style="display: inline-block" ;>
<img src="leftbrace.png">
</div>
<div class="mainAbout" style="display: inline-block" ;>
<!--- Main Name and About me Section ---->
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
<!--- End mainAbout --->
<div id="rightBrace" style="display: inline-block" ;>
<img src="rightbrace.png">
</div>
</div>
<!--- Wrapper Ends Here --->
<div class="projects">
<h2> Projects </h2>
</div>
<div class="contact">
</div>
</div>
<!--- Wrapper Ends Here --->
<footer>
</footer>
Instead of using background you could style curly-braces using pseudo selector :before and :after, thus it works like font styling, you could use transform:translate to center your intro text container, check below codes.
#box {
width: 100%;
height: 300px;
overflow: hidden;
background: #ccc;
}
#box > .cnt {
width:50%;
text-align: center;
top: 50%;
left: 50%;
position: relative;
transform: translate(-50%, -50%);
}
#box:before {
content:"{";
font-size: 250px;
position: absolute;
top: 0;
left:10%;
}
#box:after {
content: "}";
font-size: 250px;
position: absolute;
top: 0;
right:10%;
}
<div id="box">
<div class="cnt">
<h1> Benjamin Yan </h1>
<p> I am a Senior Year Computer Science student at Sacramento State <br> University, California. I strive to become a professional Web Developer. </p>
</div>
</div>
Apply margin: 0 auto; to your content class. This will work.
You need to make sure add an inner class inside each wrapper and define your desired width. And need to apply margin: 0 auto to the inner. I added demo snippet.If u want specific wrapper full width just remove innerclass that's enough you will get full width. I hope it will help you.
.wrapper {
height: 300px;
width: 100%;
background: orange;
margin-bottom: 20px;
}
.inner {
width: 70%;
margin: 0 auto;
background: pink;
height: 100%;
}
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
<div class="wrapper">
<div class="inner"></div>
</div>
The below is HTML code. I am using bootstrap 3 for the design. I placed the text over an image, but the issue occurs as it does not stays in correct position. On resizing the browser the position of the text with background gets misplaced. So please help me how to resolve this issue.
<div class = "col-xs-12">
<h3 class="cen-align">STORIES OF CHANGE</h3>
<img src="img/rig_img1.jpg" class="center-block img-responsive image-wrapper" />
<p class="img-ps">Advocating Land Rights for BPL Dalit communities in Alampur village...</p>
</div>
CSS Code:
.img-ps{
font-size:13px;
text-align:center;
position: absolute;
left:66px;
top:143px;
padding: 10px;
background-color:rgba(0,0,0,0.3);
width: 248px;
color: #FFF;
margin: 0px;
}
.image-wrapper{
position: relative;
width: 250px;
}
I don't know what exactly you need but does this works for you?
HTML:
<div class = "col-xs-12">
<h3 class="cen-align">STORIES OF CHANGE</h3>
<img src="img/rig_img1.jpg" class="image">
<p>Advocating Land Rights for BPL Dalit communities in Alampur village...</p>
</div>
CSS:
.image {
position: relative;
}
p {
position: absolute;
top: 200px;
left: 0;
width: 100%;
color: white;
}