Maybe from the title above some of you will become confused, But it exactly as the title said, I want to make this pipeline design using CSS, I think I can achieve it using border but how can I add the round bullet like in the image below?
to make it easier, my layout will look like this:
First row : Image 1 & text
second row : Text & Image 2
Third row : Image 3 & text
fourth row : Image 4
so this is some question I want to ask:
Can I make this kind of line using the border?
How can I make the line stop in the middle like before the Image 4?
How can I make the bullet in the middle of the line that will match the line even when we check it in some device (exclude the mobile view around 576px)?
Can someone help me with this problem? for the first question, I think we can use
1. First Row :
border-right: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-right-radius : 10px;
2. second Row :
border-left: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-left-radius : 10px;
3. Third Row :
border-right: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-right-radius : 10px;
4. Fourth Row :
border-left: solid 1px blue;
border-bottom : solid 1px blue;
border-bottom-left-radius : 10px;
width: 50% (?)
Edit 1
for question one currently I make this CSS code like this:
#first-row-left{
border-left: solid 3px blue;
border-bottom: solid 3px blue;
border-bottom-left-radius: 20px
}
#first-row-right{
border-bottom: solid 3px blue;
}
#second-row-left{
border-bottom: solid 3px blue;
}
#second-row-right{
border-right: solid 3px blue;
border-bottom: solid 3px blue;
border-top-right-radius: 20px;
border-bottom-right-radius: 20px
}
#third-row-left{
border-left: solid 3px blue;
border-bottom: solid 3px blue;
border-bottom-left-radius: 20px;
border-top-left-radius: 20px
}
and it looks like this
As you can see there is slight miss in before the pipeline change the row like from first to second row
Edit 2 I already make a fiddle for this, you can try it in here:
Click here to see the fiddle
Edit 3
Based on #Alexwc_ , I tried to change his code into CSS intead of SCSS, but it seems I miss something in here
SCSS from #Alexwc_ after I convert it to CSS:
this is the fiddle I made : Check in here
Here's one method. Perhaps not the cleanest, and it hasn't been adapted for mobile.
Here is a pen of the work using SCSS.
Here is a pen of the work using CSS. (Please note that I converted SCSS to CSS using this tool)
CAVEATS:
this was not put into a SO snippet because (for whatever reason) it doesn't display correctly.
I've tested only on Mac OS Chrome/Chrome Canary/FF/FFDE/Safari
On the CodePen I used SCSS
My CSS/SCSS/variables may cause some snickering as I'm no pro at it, and it feels a little hacky... but perhaps other edge-ish cases may cause the same feeling.
I did not see that you had posted your own markup while I was writing this out. Apologies for that.
The bullets can be edited to however you like, I figured the bullet styles weren't the real issue here.
CSS:
:root {
--width: 5px;
--border-radius: calc(var(--width) * 2);
--button-width: 30px;
--button-left-pos: -12.5px;
}
.row {
margin: 0 20px;
}
img {
border-radius: 10px;
}
.one, .two, .three, .four {
position: relative;
}
.one::before, .one::after, .two::before, .two::after, .three::before, .three::after, .four::before, .four::after {
position: absolute;
top: var(--button-width);
left: var(--button-left-pos);
content: "";
height: 30px;
width: 30px;
background: black;
border-radius: 100px;
}
.one::after, .two::after, .three::after, .four::after {
width: calc( var(--button-width) / 2 );
height: calc( var(--button-width) / 2 );
background: red;
top: calc(var(--button-width) + var(--button-width) / 4 );
left: -5px;
}
.two::before, .two::after {
right: var(--button-left-pos);
left: initial;
}
.two::after {
right: -5px;
}
.one::after {
width: calc( var(--button-width) / 2 );
height: calc( var(--button-width) / 2 );
background: red;
top: calc(var(--button-width) + var(--button-width) / 4 );
}
.row {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
grid-template-areas: "left right";
position: relative;
}
.row:last-child {
grid-template-areas: "border ..." "full full";
}
.row .left, .row .right {
padding: var(--button-width);
}
.one .left {
padding-top: 0;
border-left: var(--width) solid;
border-bottom: var(--width) solid;
border-bottom-left-radius: var(--width);
}
.two {
top: calc(var(--width) * -1);
}
.two .right {
border-right: var(--width) solid;
border-top: var(--width) solid;
border-top-right-radius: var(--width);
border-bottom-right-radius: var(--width);
border-bottom: var(--width) solid;
}
.three {
top: calc(var(--width) * -2);
}
.three .left {
border-left: var(--width) solid;
border-top: var(--width) solid;
border-top-left-radius: var(--width);
border-bottom-left-radius: var(--width);
}
.four {
top: calc(var(--width) * -3);
}
.four::before, .four::after {
top: 85px;
}
.four::before {
left: calc(50% - 17.5px);
}
.four::after {
top: 92.5px;
left: calc(50% - 10.5px);
}
.four .border {
height: 200px;
display: block;
border-right: var(--width) solid;
border-top-right-radius: var(--width);
position: relative;
}
.four .border::before {
content: "";
position: absolute;
height: var(--width);
background: black;
top: 0;
width: calc(100% + var(--width));
transform: rotate(180deg);
border-bottom-left-radius: var(--width);
border-top-right-radius: var(--width);
}
.border {
grid-area: border;
}
.full-width {
grid-area: full;
justify-self: center;
}
.left {
grid-area: left;
}
.right {
grid-area: right;
}
HTML:
<div class="row one">
<div class="left">
<img src="https://via.placeholder.com/450x250" alt="">
</div>
<div class="right">
<h1>Heading</h1>
<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. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<!-- one -->
<div class="row two">
<div class="left">
<h1>Heading</h1>
<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. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="right">
<img src="https://via.placeholder.com/450x250" alt="">
</div>
</div>
<!-- two -->
<div class="row three">
<div class="left">
<img src="https://via.placeholder.com/450x250" alt="">
</div>
<div class="right">
<h1>Heading</h1>
<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. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<!-- three -->
<div class="row four">
<div class="border border-top"></div>
<div class="full-width">
<img src="https://via.placeholder.com/900x500" alt=""></div>
</div>
<!-- four -->
You may consider using SVG. Following code is a sample code to draw path and circle.
<!DOCTYPE html>
<html>
<body>
<svg height="400" width="450">
<path id="lineAB" d="M 100 350 l 150 -300" stroke="red" stroke-width="3" fill="none" />
<path id="lineBC" d="M 250 50 l 150 300" stroke="red" stroke-width="3" fill="none" />
<path d="M 100 350 q 150 -300 300 0" stroke="blue" stroke-width="5" fill="none" />
<g stroke="black" stroke-width="3" fill="black">
<circle id="pointA" cx="100" cy="350" r="3" />
<circle id="pointB" cx="250" cy="50" r="3" />
<circle id="pointC" cx="400" cy="350" r="3" />
</g>
<g font-size="30" font-family="sans-serif" fill="black" stroke="none" text-anchor="middle">
<text x="100" y="350" dx="-30">A</text>
<text x="250" y="50" dy="-10">B</text>
<text x="400" y="350" dx="30">C</text>
</g>
Sorry, your browser does not support inline SVG.
</svg>
</body>
</html>
`#first-row-left:before
{
content: '';
display: inline-block;
position: absolute;
border-radius: 50%;
left: 0;
width: 10px;
height: 10px;
z-index: 3;
top: 25px;
}`
try something like this...
You can use the border-image property to draw a custom svg for your border. Have a look at this article to see an example.
The Round bullet can be done with an external div like
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div id='bullet'></div>
</body>
</html>
#bullet{
background-color:#fff310;
height:10px;
width:10px;
border-radius:50%;
border:0.1px solid red;
}
Related
For months this is the only problem I haven't been able to solve. I've hired multiple people on Freelancer to help and two gave up, and another said it was impossible.
I'm simply trying to get the text of my buttons to stay within the boundaries of the button. Right now it looks like this.
All I need to do is wrap the text if it's too long to fit the horizontal boundaries of the button, and shrink the text if it's too big to fit within the boundaries of the button. Like this:
I've tried:
Using Fitty, FitText, and other libraries which don't work at all. They'll sometimes make the text too big to fit within the boundaries of the button, and sometimes they'll make all of my text small unnecessarily.
Creating my own function by looking at clientWidth and clientHeight, and shrinking the font as necessary. When I do that, clientWidth of my elements stay the same regardless of the actual size, I've also used getComputedStyle which doesn't seem to calculate properly either.
Paying people. Again multiple people have given up, and I've spent months trying to solve this with no success.
I've created a codepen with a minimally reproducible example showing the problem.
https://codepen.io/TheNomadicAspie/pen/dyRLrej
And here is the code (I've removed all of the unnecessary code, but left in the parent divs of the buttons in case they are affecting whatever is keeping the libraries/my functions/other people from being able to do this).
<div id="screen" class="screen">
<div id="display" class="display">
<div id="bottom_bar" class="bottom-bar">
<div id="bottom_display" class="bottom-display">
<div id="answers_display" class="answers-display">
<div id="answer_container_1" class="answer-button-1">
<div id="answer_checkbox_1" class="checkbox">
</div>
<div id="answer_button_container_1" class="answer-button-container">
<button id="answer_button_1" class="button lower-button">
</button>
</div>
</div>
<div id="answer_container_2" class="answer-button-2">
<div id="answer_checkbox_2" class="checkbox">
</div>
<div id="answer_button_container_2" class="answer-button-container">
<button id="answer_button_2" class="button lower-button">
</button>
</div>
</div>
<div id="answer_container_3" class="answer-button-3">
<div id="answer_checkbox_3" class="checkbox">
</div>
<div id="answer_button_container_3" class="answer-button-container">
<button id="answer_button_3" class="button lower-button">
</button>
</div>
</div>
<div id="answer_container_4" class="answer-button-4">
<div id="answer_checkbox_4" class="checkbox">
</div>
<div id="answer_button_container_4" class="answer-button-container">
<button id="answer_button_4" class="button lower-button">
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<link href="styles.css" rel="stylesheet">
* {
outline: none;
opacity: 1;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html,
body {
position: fixed;
height: 100%;
background-color: #26004b;
font-size: 2vh;
margin: 0 auto;
font-family: open_sans;
}
.screen {
position: absolute;
height: 100%;
}
.title {
grid-column: 2/3;
position: relative;
color: #f5f5f5;
height: 100%;
width: 100%;
margin: 0 auto;
text-align: center;
justify-content: center;
align-items: center;
font-family: hack;
font-size: clamp(2vw, 8vw, 10vh);
display: flex;
top: 0%;
}
.display {
position: relative;
height: 86.286%;
width: 100vw;
}
.bottom-bar {
display: grid;
grid-template-columns: 38.2% 61.8%;
position: relative;
height: 38.2%;
width: 100vw;
bottom: 0%;
}
.character {
grid-column: 1/2;
position: relative;
background-size: contain;
background-repeat: no-repeat;
background-position-y: bottom;
background-position-x: center;
}
.bottom-display {
grid-column: 2/3;
position: relative;
height: 100%;
padding-right: 5vw;
padding-top: 1%;
padding-bottom: 3%;
}
.answers-display {
display: grid;
gap: 1%;
max-height: 99%;
grid-template-columns: 100%;
grid-template-rows: 25% 25% 25% 25%;
height: 100%;
}
.answer-button-1 {
position: relative;
grid-row: 1/2;
display: grid;
grid-template-columns: 20% 80%;
height: 98%;
}
.answer-button-2 {
position: relative;
grid-row: 2/3;
display: grid;
grid-template-columns: 20% 80%;
height: 98%;
}
.answer-button-3 {
position: relative;
grid-row: 3/4;
display: grid;
grid-template-columns: 20% 80%;
height: 99%;
}
.answer-button-4 {
position: relative;
grid-row: 4/5;
display: grid;
grid-template-columns: 20% 80%;
height: 99%;
width: 100%;
}
.checkbox {
grid-column: 1/2;
height: 100%;
width: 100%;
overflow: hidden;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
object-fit: contain;
}
.answer-button-container {
grid-column: 2/3;
padding-left: 2%;
height: 100%;
}
.answer-button-container button {
width: 100%;
padding-left: 1%;
padding-right: 1%;
padding-top: 2%;
padding-bottom: 2%;
}
.button {
display: block;
position: relative;
height: 100%;
width: 100%;
background-color: black; /*Button Color*/
color: #f5f5f5;
font-family: open_sans;
font-size: 1.5rem;
border-radius: 20px;
text-decoration: none;
box-shadow: 0.1em 0.2em black;
cursor: pointer;
}
.lower-button {
white-space: nowrap;
}
const answer_button_1 = document.getElementById("answer_button_1");
const answer_button_2 = document.getElementById("answer_button_2");
const answer_button_3 = document.getElementById("answer_button_3");
const answer_button_4 = document.getElementById("answer_button_4");
answer_button_1.innerText = "This is a really really really really really really really really really really really really really really really really really really really really really long test answer";
answer_button_2.innerText = "This is a pretty long test answer but not as long as the other one";
answer_button_3.innerText = "This is a fairly short test answer";
answer_button_4.innerText = "Really short answer";
Edit: To clarify, I need the button to not get larger to fit the text, I need the text to get smaller to fit the button.
This here does the job by wrapping the text and making the box larger, it does however mess up the spacing between the boxes. Took me a few minutes, hope it helps :)
#answer_button_1 {
height: auto;
max-width:30wv;
hyphens: auto;
white-space: normal;
}
The Spacing between the buttons can be fixed by removing the following lines from .answers-display:
grid-template-rows: 25% 25% 25% 25%;
height: 100%;
Hmmmm. Yes, this is a tricky one. Using this article as inspiration, I was able to come up with the following solution. The technique used is to start with a really small font size (I have set minSize to 8 for this example) and test whether the text overflows its container; if the text does not overflow, increase the font size by a small amount (I've set step to 0.5) and re-test; then if the text overflows, revert to the previous font size.
Note, however, that it uses regular divs rather than buttons. The solution relies on a set of nested elements, which the button element does not support. Buttons also seem to have some built-in padding or sizing which is difficult to control. I suspect that Fitty and FitText don't work on buttons. I did try swapping the innermost divs with buttons in this snippet, and while it still works fairly well, it's more complicated and doesn't look as good. The only reason to prefer a button over a div is purely a semantic one, so I'd recommend sticking to using divs. Just add your click handler and off you go.
You can try different values for minSize, step and so on to see how that affects the result. Note that because I have used a minSize of 8, there comes a point where very long texts still overflow the button. Setting minSize to 0 avoids this -- the text fits on the button regardless of its length, but for some reason the text doesn't quite fill the button: the bottom padding appears larger. But your results may vary.
const isOverflown = ({ clientHeight, scrollHeight }) => scrollHeight > clientHeight
const resizeText = ({ element, elements, minSize = 10, maxSize = 512, step = 1, unit = 'px' }) => {
(elements || [element]).forEach(el => {
let i = minSize
let overflow = false
const parent = el.parentNode
while (!overflow && i < maxSize) {
el.style.fontSize = `${i}${unit}`
overflow = isOverflown(parent)
if (!overflow) i += step
}
// revert to last state where no overflow happened
el.style.fontSize = `${i - step}${unit}`
})
}
resizeText({
elements: document.querySelectorAll('.button>div>div'),
minSize: 8,
step: 0.5
})
body {
background: #33A;
font-family: sans-serif;
}
.button {
margin: 1em 0;
width: 300px;
height: 50px;
padding: 10px 10px 10px 15px;
color: #f5f5f5;
background-color: black;
border: 1px outset;
border-radius: 20px;
box-shadow: 0.1em 0.2em black;
cursor: pointer;
text-align: center;
}
.button>div {
width: 100%;
height: 100%;
}
<div class="button">
<div>
<div>
This text
</div>
</div>
</div>
<div class="button">
<div>
<div>
This Text is a bit longer
and should be wrapped correctly
</div>
</div>
</div>
<div class="button">
<div>
<div>
This text is the longest and should appear quite small.
This text is the longest and should appear quite small.
</div>
</div>
</div>
<div class="button">
<div>
<div>
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.
</div>
</div>
</div>
<div class="button">
<div>
<div>
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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
<div class="button">
<div>
<div>
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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
It's a real pity that web standards do not currently provide a mechanism for automatically adjusting font size to fill a fixed size container. There are mechanisms to do it with images, so why not with text? I myself have had regular situations over the years where I have wished this were possible.
I am curious, though, as to why it is so important for you for the buttons to be a fixed size? Doesn't readability become a problem when there's a lot of text, and the font-size gets so small? Would it not be a better solution to simply allow the buttons to grow vertically to contain longer pieces of text? Or even truncate the text at a maximum number of characters or words, and add an ellipsis to indicate that truncation occurred?
How do create a CSS so that My content is on the left side of the screen and I place the vertical Adsense on the right side, however, the page opens on the smartphone, the Adsense banner move under My content?
You should learn first about Responsive Web Design.
According to this, there are many ways to make a page responsive.
Flexbox, Grid, MediaQueries & ...
I'm showing you an example using FlexBox.
You can also read about CSS Grid here.
And about Media Queries here.
Result: As you can see, if the total width of the two boxes would be over 520px, then it will break into a new line.
const check = () => {
let firstBoxInput = document.querySelector('.first-child-width').value;
let secondBoxInput = document.querySelector('.second-child-width').value;
const firstBox = document.querySelector('.first-child');
const secondBox = document.querySelector('.second-child');
firstBox.style.width = `${firstBoxInput}px`;
secondBox.style.width = `${secondBoxInput}px`;
};
document.querySelector('button').addEventListener('click', check);
* {
margin: 0;
padding: 0;
box-sizing: border-box
}
.container {
display: flex;
flex-wrap: wrap;
width: 520px;
border: 1px solid black
}
.container .first-child {
display: flex;
align-items: center;
justify-content: center;
background-color: orange;
border: 1px solid black;
width: 300px;
height: 300px
}
.container .second-child {
display: flex;
align-items: center;
justify-content: center;
background-color: green;
border: 1px solid black;
width: 200px;
height: 300px
}
<input type="number" class="first-child-width" placeholder="First Box Width in px">
<input type="number" class="second-child-width" placeholder="Second Box Width in px">
<button type="button">Click</button>
<section class="container">
<article class="first-child">First Child</article>
<article class="second-child">Second Child</article>
</section>
Media queries can be used to check many things, such as:
width and height of the viewport
width and height of the device
orientation (is the tablet/phone in landscape or portrait mode?)
resolution
Using media queries are a popular technique for delivering a tailored style sheet to desktops, laptops, tablets, and mobile phones
.container{
display: flex;
flex-direction: row;
}
.text{
text-align: justify;
padding: 0 10px;
}
.adsense{
width:100px;
background-color:#666;
color:#ffffff;
}
#media (max-width: 600px) {
.container{
flex-direction: column;
}
.adsense{
margin-top:20px;
width:100%;
height:200px;
background-color:#666;
color:#ffffff;
}
}
<div class="container">
<div class='text'>
<h3>My Content</h3>
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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class='adsense'>
adsense
</div>
</div>
I've tried alot of solutions and maybe I just implemented them wrongly for my code but I need help as my yr 11 task is due in 1 more day! Someone save me aha.
I apologize for not having a fiddle example to use as I don't know how to set it up or whatever, also the site just wants me to add more details so I'm just gonna keep writing till it lets me post cause I'm tired af and can't think. Whoever helps me your a bloody legend, cheers from straya :)
.slideshow {
display: none;
padding: 10px 0 10px 0;
margin-top: -50px;
font-size: 25px;
overflow-y: hidden;
}
.slide_selection {
display: inline-block;
padding: 20px 30px;
}
.slide_selection img {
height: 40px;
padding: 5px;
border-radius: 250px;
border: #00000099 2px solid;
transition: all .3s ease-in-out, border .5s;
}
.slide_selection img:hover {
background-color: #00000099;
}
.slide_icon {
display: inline;
float: left;
padding: 0 30px 0 30px;
transition: all .15s ease-in-out;
}
.slide_icon:hover {
transform: scale(1.3);
}
figcaption {
font-size: 10px;
font-weight: bold;
}
.slide_content {
background-color: #00000025;
box-shadow: inset 0 15px 10px -15px black, inset 0 -13px 10px -15px black;
margin: -10px 0 0 0;
padding: 30px 0;
display: inline-block;
}
.slide_content img {
height: 95px;
}
.slide_image {
width: 25%;
height: 100%;
float: left;
}
.slide_info {
display: inline-block;
float: right;
width: 75%;
text-align: left;
}
<div class="slideshow">
<div class="slide_selection">
<div onclick="test(1);" class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>WinRar</figcaption>
</div>
<div class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>OllyDBG</figcaption>
</div>
<div class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>NortonAV</figcaption>
</div>
</div>
<div class="slide_content">
<div class="slide_image">
<img src="https://i.stack.imgur.com/iplpF.png" alt="" />
</div>
<div class="slide_info">
<h4>Software Type: </h4>
<h4>Release Date: </h4>
<p>Winrar Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
Can I be consider as bloody legend?
Codepen: http://codepen.io/anon/pen/NpoGPr
What I did is use flexbox to center the image.
justify-content is for horizontal centering
align-items is for vertical centering
.slideshow {
padding: 10px 0 10px 0;
margin-top: -50px;
font-size: 25px;
overflow-y: hidden;
}
.slide_selection {
display: inline-block;
padding: 20px 30px;
}
.slide_selection img {
height: 40px;
padding: 5px;
border-radius: 250px;
border: #00000099 2px solid;
transition: all .3s ease-in-out, border .5s;
}
.slide_selection img:hover {
background-color: #00000099;
}
.slide_icon {
display: inline;
float: left;
padding: 0 30px 0 30px;
transition: all .15s ease-in-out;
}
.slide_icon:hover {
transform: scale(1.3);
}
figcaption {
font-size: 10px;
font-weight: bold;
}
.slide_content {
background-color: #00000025;
box-shadow: inset 0 15px 10px -15px black, inset 0 -13px 10px -15px black;
margin: -10px 0 0 0;
padding: 30px 0;
display: flex;
height: 100%;
}
.slide_content img {
height: 95px;
}
.slide_image {
width: 25%;
display: flex;
align-items: center;
justify-content: center;
}
.slide_info {
display: inline-block;
width: 75%;
text-align: left;
}
<div class="slideshow">
<div class="slide_selection">
<div onclick="test(1);" class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>WinRar</figcaption>
</div>
<div class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>OllyDBG</figcaption>
</div>
<div class="slide_icon"> <img src="https://i.stack.imgur.com/iplpF.png" alt="" />
<figcaption>NortonAV</figcaption>
</div>
</div>
<div class="slide_content">
<div class="slide_image">
<img src="https://i.stack.imgur.com/iplpF.png" alt="" />
</div>
<div class="slide_info">
<h4>Software Type: </h4>
<h4>Release Date: </h4>
<p>Winrar Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis
aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
i did nt understand your code but i think you need a div container you divise it as much as you need then you put your image in the middle of the page here is an simple example
<div class="container">
<div class="row">
<div class="igreen col-sm-5 col-md-5 col-lg-5">this is will be green area</div>
<div class="col-sm-2 col-md-2 col-lg-2"></div>
<div class="col-sm-5 col-md-5 col-lg-5">step1</div>
<div class="col-sm-5 col-md-5 col-lg-5">step1</div>
<div class="col-sm-2 col-md-2 col-lg-2"> <img src="my_image.png"></div>
<div class="ired col-sm-5 col-md-5 col-lg-5">this is will be a red area</div>
<div class="col-sm-5 col-md-5 col-lg-5">step1</div>
<div class="iblue col-sm-2 col-md-2 col-lg-2">this is the blue </div>
<div class="col-sm-5 col-md-5 col-lg-5">step1</div>
</div>
this is a container
We have a problem where we need to have a list of divs with dynamic content.
There will always be 2 divs per row. Both of those elements should have the same height.
Currently we have a solution which sets the height of the boxes with JavaScript, but it's not very performant, since it recalculates the sizes on every resize (Responsive design).
Is there a solution without fixed height values?
Important: The boxes still need to be padded, and the padding needs to be in percent (currently 4% margin on div)
Jsfiddle: http://jsfiddle.net/6dmwU/
<div class="boxes">
<div class="box-wrapper">
<div class="box" style="height: 203px;">
<p class="box-title">Lorem Vulputate</p>
<p>On corerias sunturero in cullabore dolestionet apid utatur On corerias sunturero in cullabore dolestionet apid utatur</p>
</div>
<div class="box" style="height: 203px;">
<p class="box-title">Egestas Pharetra</p>
<p>On corerias sunturero in cullabore dolestionet apid utatur</p>
</div>
</div>
<div class="box-wrapper">
<div class="box" style="height: 151px;">
<p class="box-title">Vulputate Egestas</p>
<p>On corerias sunturero in cullabore dolestionet apid utatur</p>
</div>
<div class="box" style="height: 151px;">
<p class="box-title">Egestas Pharetra</p>
<p>On corerias sunturero in cullabore dolestionet apid utatur</p>
</div>
</div>
</div>
Any help will be very appreciated
You can use a flex model for this:
.boxes .box
{
margin-left: 2%;
margin-bottom: 2%;
width: 50%;
padding: 4%;
border: 1px solid #b6b6b6;
border: 0.0625rem solid #b6b6b6;
box-sizing: border-box;
}
.box-wrapper
{
width: 100%;
display: -webkit-box;
display: -moz-box;
display: -webkit-flexbox;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
jsFIddle
This way every row will be the height of the highest child element.
However the support for this is limited.
So if you rather not use this method you can transform you structure in a table structure. This way every row will be the height of the highest child element.
.boxes .box
{
display: table-cell;
margin-left: 2%;
margin-bottom: 2%;
width: 50%;
padding: 4%;
border: 1px solid #b6b6b6;
border: 0.0625rem solid #b6b6b6;
box-sizing: border-box;
}
.box-wrapper
{
display: table-row;
}
.boxes
{
display: table;
border-collapse: separate;
border-spacing: 5px;
}
Because margin doesn't work between table-cells i used border-spacing to define the seperation between the cells.
jsFiddle
Try this
.boxes .box {
float: left;
margin-left: 2%;
margin-bottom: 2%;
width: 38%;
padding: 4%;
border: 1px solid #b6b6b6;
border: 0.0625rem solid #b6b6b6;
box-sizing: border-box;
display:inline-block
}
.box-wrapper,.boxes{
display:inline-block;
width:100%;
}
Fiddle
Have a look at this fiddle You can use display:table-cell;
CSS:
.row {
display: table;
width: 100%;
}
.left {
width:50%;
background: blue;
display:table-cell;
}
.right {
width:50%;
background: red;
display:table-cell;
}
HTML
<div class='row'>
<div class='left'>
"Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</div>
<div class='right'>
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos
</div>
</div>
I use flexbox, it's magic ^^ :
HTML
<div class="boxes">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
CSS
.boxes {
display: flex;
flex-wrap: wrap;
}
.box {
margin: 0 1% 1% 0;
width: 48%;
}
CODEPEN DEMO
Complete guide to flexbox on css-trick
As far as I can tell, it is not possible to place a CSS background image 1em from the right border of any block, neither is it possible to place a image 1em from the bottom.
The following code places the background image 1em from the left and 2em from the top.
<div class="foo" style="background: url('bar.png') no-repeat 1em 2em">
Some text here
</div>
Is there any way in CSS to specify that the background image should be "this far from the right edge" if the size of the box is dynamic and assuming that you cannot change the HTML?
(Percentages won't work, since the box can change size)
If this is not possible, what is the smallest amount of change you need to make to the HTML?
This is the workaround I came up with:
<style>
div.background
{
float: right;
background: url('bar.png') no-repeat top left;
margin-right: 1em;
width: 16px;
height: 16px;
}
</style>
<div class="foo">
<div class="background" style=""> </div>
Some text here
</div>
The CSS3 background-position spec allows you to change the anchor point from the top left to anything you want. For example, the following will set the lower bottom corner of the image 1em from the right and 2px from the bottom:
background-position: right 1em bottom 2px;
Confirmed to work in:
IE9/10, Firefox 13+, Chrome 26+, Opera 11+, Seamonkey 2.14+, Lunascape 6.8.0
As of April 2013, only IE6-8 and some fringe browsers lack support.
Here's a test page: http://jsbin.com/osojuz/1/edit
Elements with position: absolute; can be positioned by their right edge.
So, if you don't mind a minor change to the html, do this:
<div id="the-box">
<img id="the-box-bg" src="bar.png" />
Text text text text....
</div>
(...)
#the-box {
position: relative;
}
#the-box-bg {
position: absolute;
right: 1em;
z-index: -1;
}
You could of course also use absolute positioning of a second div, with a repeating background. But then you would have to set the size of the (inner) div in CSS.
You could try something like this:
<style type="text/css" media="screen">
#outer {
position: relative;
top: -1em;
left: -1em;
margin: 1em 0 0 1em;
outline: thin solid #F00;
background: url(http://i.stackoverflow.com/Content/Img/stackoverflow-logo-250.png) no-repeat 100% 100%;
}
#inner {
outline: thin solid #0F0;
position: relative;
top: 1em;
left: 1em;
}
</style>
<div id="outer">
<div id="inner">
Lorem ipsum dolor sit amet, consectetur adipisicing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
Edit: Looking forward to CSS 3 background-position.
After some research the actual x pixel length of the background position is always counted from the left side of the element. The only way to make this work (without using other elements) would be to use javascript, calculate the left length given the elements width:
var rightMargin = "10"; // in pixels
var imageWidth = "16";
var left = element.style.clientWidth - imageWidth - rightMargin;
element.style.backgroundPosition = "0px " + left + "px";