I've been given a design to develop and the design uses numerous circular layout items and I'm a little unsure how to go about this, I've tried using SVGs, PNGs etc but it's not playing ball.
For example, this section of the design looks like this
But when I try using an SVG, I end up with this
That ^ show a section with a grey background and above is an SVG which has a grey bottom and green line through it, I've tried using an SVG which is white on the top, grey on the bottom and has that green line through the middle, but when I try to replicate the design I run into the problem that SVG doesn't have the image so it cuts off as you can see. Here is an example of my code:
HTML:
<img src="img/line-05.svg" class="svg" />
<section class="bgYellowGrey">
<div class="column two">
<div class="numWrapper"><p class="number">2</p></div>
<h2>Title</h2>
<h3>Subtitle</h3>
<p>Paragraph text</p>
</div>
<div class="column two">
<img id="image-03" src="img/third-image.png" />
</div>
</section>
CSS (of which is relevant):
section{
position: relative;
float: left;
}
.column{
float: left;
}
.two{
padding: 10px 2%;
width: 46%;
}
#image-03{
margin-top: -150px;
}
.svg{
position: relative;
width: 100%;
z-index: 99999;
}
The SVG in question is this (screenshot from illustrator):
The design is totally based around this layout unfortunately. Is there any other convention or simple method of doing replicating the design? I guess I just need to find a way to clip into a div/svg? Any help would be appreciated.
This may be hard to explain but do tell me to explain further on bits and I shall.
Related
I have an image in a div next to some text in a div, and I have centred the text to some satisfaction in the desktop, but the text is not responsive. When I shrink the browser to mobile size the text is superimposed on the responsive images. You can see here: https://www.artisanbelle.com/ Scroll down to the block where the testimonials are and you'll see what I mean.
There are multiple divs of class 'pic-testimonial'. Before I added translate/transform to center the text, my text blocks were responsive in mobile but they were not centered. I need an approach that allows me to center the text within that div but which maintains the responsiveness of the overall structure. What I have doesn't do that and I am not sure what to do. The 'center' tag did not work. To clarify, without the transform, the text was sitting at the top of the large div (the size of the div is fine btw). The transform created the effect that I wanted but only at desktop level. It is wonky at mobile, as described. Does anyone have an alternative way to center text within a div block that is responsive?
Also I would prefer a solution that is not deprecated in HTML5 if possible. Thanks.
I have tried the following code: (snippet only provided)
<div class="testimonial-container">
<div class="pic-testimonial">
<div class="testimonial-imga"><figure class="photo1"><img class="testimonial-photo" src="http://www.artisanbelle.com/images/stories/amandac.jpg" alt="Amanda C"></figure> </div>
<div class="testimonial-texta"><div class="test-text">
<p>"These white topaz earrings are gorgeous. The stones catch the light and are so pretty. They can be dressed up or down and the craftsmanship is top quality. A great pair of earrings that go with everything." <br>- Amanda Coldwell</p> </div> </div>
</div>
</div>
CSS:
.test-text {
position: relative;
}
.test-text p {
margin: 0;
position: absolute;
top: 50%;
left: 25%;
transform: translate(-16%, 80%);
text-align: center;
}
.testimonial-imga, .testimonial-imgb {
float: left;
}
.testimonial-texta, .testimonial-textb {
float: left;
padding: 15px;
` background-color: #DDE1E4;
width: 50%;
text-align: center;
font-size: 1.3em;
}
.testimonial-container {
width: 80%;
border: none;
margin: auto;
}
Expected/desired output: text centred responsively across all devices
Actual output: Text only centred across desktop device at normal browser size. Text superimposed on images when browser is mobile size
Images are fine and already responsive.
Use center tags
.test-text {
position: relative;
}
.test-text p {
margin: 0;
position: absolute;
top: 50%;
left: 25%;
transform: translate(-16%, 80%);
text-align: center;
}
<center>
<div class="testimonial-container">
<div class="pic-testimonial">
<div class="testimonial-imga">
<figure class="photo1"><img class="testimonial-photo" src="http://www.artisanbelle.com/images/stories/amandac.jpg" alt="Amanda C"></figure>
</div>
<div class="testimonial-texta">
<div class="test-text">
<p>"These white topaz earrings are gorgeous. The stones catch the light and are so pretty. They can be dressed up or down and the craftsmanship is top quality. A great pair of earrings that go with everything." <br>- Amanda Coldwell</p>
</div>
</div>
</div>
</div>
</center>
read more at
Never mind. I fixed the problem. I moved the text transform to the desktop section (media queries) and made the width 100% for the .testimonial-texta, .testimonial-textb width attribute.
I am creating one of those scroll-through websites where you just scroll down through pages. My pages alternate black and white background.
I have the following page:
<div class="row>
<div class="col-xs-9 introduction">
<p> TEXT </p>
</div>
</div>
with the following CSS:
.introduction {
height: 120%;
padding-top: 150px;
text-align: center;
background: #eee;
min-height: 800px;
}
My problem is that when I make the window of my browser narrow enough, the TEXT in my intro section overflows the white background and spills over to the black section.
How do I specify the size of the class so that all the text is always within the white background??
Thanks!
It is because you cannot read the documentation.
<div class="col-xs-9 introduction">
<p> TEXT </p>
</div>
Here in this code this class 'col-xs-9', xs is used to make sure that the column remains horizontal at all times so your responsive settings aren't properly arranged the way they should be.
I'll suggest that you read the documentation about the grid system a little.
use this instead
<div class="col-md-9 introduction">
<p> TEXT </p>
</div>
it wont give you any problem.
You can use overflow for the text parent
To hide the text or make scroll
Or you can use nicescroll vs slimscroll
Overflow MDN
you can try this css to fix:
.introduction {
height: 100vh;
padding-top: 150px;
text-align: center;
background: #eee;
max-height:100%;
}
Okay, this seems to be an issue with so many potential solutions but none that will work for what I want to do. I always want to display perfect circles, even if the underlying image is not a perfect circle. But, I don't want to specify an image dimension by px because I want it to be responsive. It seems that no matter which solution I try, the circles always either become warped into ovals or the picture dimensions completely take over and make it gigantic.
HTML:
<div class='item-image'>
<img class='img-circle img-responsive img-center' src='#' />
</div>
Goal:
Regardless of the image size (rectangles), I want the part of the image beneath the red circle to show through.
The best way to do this is per overlay. And make the circle with CSS!
<div class="wrapper">
<img src="#" class="img-responsive">
<div class="circle"></div>
</div>
.wrapper has position: relative and .circle has position: absolute and border-radius: 100%.
The wrapper has to be positioned with inline-block. Center the wrapper with text-align: center.
Center an absolute positioned element as follows:
.el {
position: absolute;
top: 50%;
margin-top: -(height / 2)%;
left: 50%;
margin-left: -(width / 2)%;
}
If you want the image inside the circle, make the circle bigger.
Example
HTML:
<div class="circle">
</div>
and use css for image in background:
.circle{
border: 2px solid red;
width: 200px;
height: 200px;
border-radius:100%;
background-image: url('')
}
check the fiddle
I am currently trying to use svg files instead of images for modern browsers on a new fluid site. The idea is to use an SVG as a background image on a fluid div which can then be changed on hover and we can use modernizer (or similar) to fallback to the use of img backgrounds for unsupported browsers.
In theory this is all fine however on certain browsers (particularly Firefox) the right and bottom edges of the svgs have some strange pixelation at certain sizes which doesn't happen for imgs.
So if you view http://jsfiddle.net/deshg/xuq6812g/ you can see a grid of 4 x 25% columns each with a div or img (that is 100% width). Each one has either a div with svg or img background or an img element with the svg/img as the src. If you view this in FF and make it bigger/smaller you'll see at certain sizes the degradation i'm talking about. You can also see this in the image below (the areas circled in blue are the degraded bits which you can see occurs on the svg but not the img).
Can anyone shed some light on why this is happening and how to prevent it as it makes SVGs largely unusable in this way if it can't be fixed
CSS
body, html {
height: 100%;
}
body {
margin: 0;
padding: 0;
}
.container {
float: left;
width: 25%;
height: 100%;
}
.container img {
width: 100%;
}
.container div {
background-size: cover;
width: 100%;
padding-top: 100%;
}
HTML
<div class="container">
BACKGROUND SVG:<br>
<div style="background-image: url('https://dl.dropboxusercontent.com/s/rga8anccnpyublh/svg.svg');">
</div>
</div>
<div class="container">
BACKGROUND IMG:<br>
<div style="background-image: url('https://dl.dropboxusercontent.com/s/rb1u7l90q9ny8bh/img.png');">
</div>
</div>
<div class="container">
SVG IN IMG TAG:<br>
<img src="https://dl.dropboxusercontent.com/s/rga8anccnpyublh/svg.svg" alt="">
</div>
<div class="container">
IMG IN IMG TAG:<br>
<img src="https://dl.dropboxusercontent.com/s/rb1u7l90q9ny8bh/img.png" alt="">
</div>
From working with vector images for years and years, when you crop them accurately, yet they need aliasing, then the crop looks odd -- flattened at the curves. So circles, text, logos, and so forth need some extra edge in the view box. Here I've add a lot more, but you get the idea.
DEMO with before and after: http://jsbin.com/buquw/1/edit
ORIGINAL -- cropped accurately, but too close, because this image needs aliasing.
NEW VERSION -- you don't need this much, used to exaggerate the situation:
I have a thumbnail image and another smaller image which overlaps the thumbnail image. But the padding changes for the smaller overlapping image as I zoom in and out and the problem exist only with the CHROME browser. Its working fine with IE and firefox. I tried using percentage to set the padding values for the smaller image but the problem still exist.
Here are the images.
This is the HTML
<div class="car-item">
<div class=" car-image">
<img src="/~/media/images/thumb.ashx" alt="Image 1" />
</div>
<div class="car video">
VIDEO
</div>
<div>
position for car video is absolute
position for car item is relative
and for car-image is static
You will have issues at times when using percentages. This is a good example of when to use absolute positioning.
I have no idea what your code looks like so here is a basic example of how to accomplish what you have pictured above with absolute positioning. I used a span tag instead of an additional image tag but it should work all the same.
You might have to modify your HTML and CSS a little furthor to get it to work in your environment.
http://jsfiddle.net/6C8gT/
Here is an updated jsFiddle (http://jsfiddle.net/6C8gT/1/) that uses your markup and another one with reduced markup (http://jsfiddle.net/6C8gT/2/). You don't really need those DIVs unless you have plans for them in the future.
I just did what I have posted below but modified the CSS to match your HTML. You'll have to check out the jsFiddles.
HTML
<div class="container">
<img class="thumb" src="http://lorempixel.com/300/200/" />
<span>Video</span>
</div>
CSS
.container {
position: relative;
}
.container img {
display: block;
}
.container span {
color: white;
background-color: black;
padding: 5px 10px;
position: absolute;
left: 0;
bottom: 0;
}