I am quite new to html/css, and I spent some time writing my own website from scratch. I have understood the very basics of the thing, but many subtleties are still unclear in my mind. Currently, I am unable to achieve a specific feature on my website, and I was hoping that maybe some of you would come up with a simple solution.
Here is what my website looks like: the colors are here to make things clearer. The four blocks "converge" toward the focal point. The top left part "Research interests" is dedicated to contain short descriptions, while the top right part "PhD thesis" is dedicated to contain either large texts or pictures. From now on, I will only focus on the top right part, where my problem occurs.
Green part :
#maindisplay
{
display: inline-block;
position: relative;
text-align: left;
width: 66.6%;
height: 80.0%;
float: right;
background-color: green;
}
Red part :
#maindisplay article
{
background-color: red;
font-family: Conv_verdana, sans-serif;
display: inline-block;
position: relative;
margin-left: 1.5%;
top: 10%;
width: 70.0%;
height: 75.0%;
overflow: auto;
}
Dark gray part :
#maindisplay p
{
background-color: gray;
font-weight: normal;
font-size: 90%;
position: absolute;
bottom: -30px;
}
I get my bottom alignment for the #maindisplay paragraphs by absolute positioning them inside the relative positioned article (and therefore, the "overflow: auto;" is here totally useless). When the text is short enough, this works like a charm and the result is exactly what I want it to be. However, when the text is longer, or when the screen is smaller (typically, my laptop), I would like things to look like this : the top of the text appears first, and a scroll bar is available. When the text is scrolled to the bottom, the bottom of the scrolled text is aligned with the bottom of the top left part, as it is in the first picture. This is achieved by setting :
#maindisplay p
{
background-color: gray;
font-weight: normal;
font-size: 90%;
position: relative;
margin: 0;
padding: 0;
bottom: 0;
}
So here is my problem : I would like the first behavior when the text is short enough, and the second behavior when it is longer than the #maindisplay article div. I was hoping that this could be done in a css-only way but I have looked for quite some time and now I am unsure about this (please note that I know precisely nothing about the javascript/jquery stuff). I am not allergic to tables, but I just don't see how to use them here.
Please let me know if there is anything unclear about this, and thanks in advance for your answers !
here's a fiddle making what you need http://jsfiddle.net/7N6Gp/ or http://jsfiddle.net/7N6Gp/1/
you need 2 div's for this one
the holder div that has position: relative;
.holder {
width: 500px;
height: 500px;
position: relative;
}
and a content div that has overflow: auto and max-height
.content {
width: 500px;
max-height: 500px;
overflow: auto;
position: absolute;
bottom: 0;
left: 0;
}
with your code . you need to wrap content in a div not p . p should only contain text or inline elements . and from your pictures it looks like it contains titles and other paragraphs (block elements)
#maindisplay p change into #maindisplay div.content
Related
I'm trying to recreate something, which I myself did by mistake:
https://bgiltphotos.files.wordpress.com/2015/09/img.jpg
It was my very first CSS attempt, and I kept adding selectors in a stopgap fashion. Then I decided to rewrite the file, and did not save the original...
This has an img position:absolute and an h1 in the header section, and then comes the article text. What I can't reproduce is the positioning of the image for the first three lines of the text: it's between the text and the background color (I then reversed the text color just for these three lines). Whatever I tried now, I either have the image covering both text and background color, or else the background color covering the image from the first line of text.
Here is the current CSS:
html {
background-color: #5F5F5F;
}
img.shost {
position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
div#headertext {
position: relative;
top: 5em;
left: 2.0em;
width: 60em;
margin-left: auto;
margin-right: auto;
text-align: left;
}
div#articleMain {
position: relative;
top: 10em;
width: 60em;
margin-left: auto;
margin-right: auto;
background-color: #fdfdf9;
}
Any help would be very much appreciated!
Solved it – had to give the background-color property to body and not to article.
Thanks for the help, guys!
Assuming img.shost is your image just add a property top and mess around with the variables until you find your desired image position
Heres a sloppy Codepen http://codepen.io/noobskie/pen/MaYdbj
just change the top:-120%; and you can see what I mean
please try to give the image z-index= -1;
it should work if you give a z-index value to the relative positioned parent
On my homepage, I'm trying to make three images span the entire width of the browser window. See my site here: http://accelfoods.com. I want the last 3 images on the page (About AccelFoods, Industry Engagement, Portfolio Companies) to be the same width as the image directly under the navigation.
I've figured out how to control #page-body and can make the image go to the edge of the left side (like this: http://imgur.com/gfXPyPK). But I don't know how to make the white space on the right disappear.
I've commented this CSS out for now until I figure it out, but here's what I'm using to manipulate the images:
#page-body {
margin-left: 0px;
padding-right: 0px;
border-right: 0px;
margin-right: 0px;
overflow-x:hidden;
width: 100%;
}
Any help would be greatly appreciated, thanks!
first of all, remove "max-size" parameter from:
#banner-area, #page-body, #page-footer{
width: auto;
}
then add this:
.sqs-block-content {
width: 100%;
}
.image-block-outer-wrapper.layout-caption-hidden {
display: block;
float: left;
position: relative;
width: 100%;
}
.sqs-block-image .intrinsic {
display: block;
float: left;
margin: auto;
max-width: none !important;
position: relative;
width: 100% !important;
}
but there's also script adding a strict width for this intrinsic class, I cannot see that from the first glance, it's kind of encription there and it will take time to understand it... though, the suggestion I'm giving you here definitely overrides the script.
P.S.
I would reccomend you not to use this kind of sitebuilder(s) (you definitely use some kind of) - because there's pretty tough class generator and if you need further updates there -you'll get pretty much more troubles.
Hi
On our website I have a page where there are Buy Now buttons
https://www.nutricentre.com/m-300-herbs-hands-healing.aspx
The styling that controls this is
.item .price {
color:#8c9c54;
font-size:14px;
font-weight: bold;
/*
position: absolute;
bottom: 48px;
left: 0px;
width: 150px;
*/
text-align: center;
margin-bottom: 45px;
}
.item a.blue_btn {
position: absolute;
bottom: 10px;
left: 15px;
cursor: pointer;
}
Any idea how I can get this aligned in a straight line regardless of the text above?
You don't have to change the css of the button, but from the whole item:
just add:
.item{
height: 380px;
}
Of course, you have to care about the maximum item-height: your value must not be less, or the price won't be visible anymore.
In this case, min-height would be the better alternative.
I would recommend setting a min-height: 370px; for the easiest solution.
You do not want to set a static height for this because if you have an item with a longer description it will not automatically add space but just cram everything in.
Add a static height to .item
height:375px;
The height:auto; declaration tells .item to expand as big as it needs to be to fit everything in, so the tops of the divs line up, but since they are different heights, the bottoms are staggered.
As some of my co-responders have noted, min-height is also an acceptable option, until you have an item with enough text that item expands past the min-height value, at which point they will begin to expand and stagger again.
This should point you in the right direction: http://jsfiddle.net/v9grm/
Create a grid and with the help of display: table make the columns the same height. Then place the button at the bottom of the column with position: absolute.
We are using the twitter bootstrap thumbnails.
We are adding a description underneath the same as in the bootstrap documentation.
The difference is that we don't have a size specified (the documentation uses .span4) on our thumbnails, instead the content sizes them.
This works great, except we want one difference, we don't want a long caption to extend the thumbnail, instead we want the extra caption length to be be hidden.
This would be easy if we were using fixed width's but since we are not I have no idea how to do this;
Here is a jsfiddle playground: http://jsfiddle.net/BbCQK/
I thought maybe I could just do:
.caption {
max-width: 100%;
text-overflow: ellipses;
}
But that doesn't work, it just stretches the container anyway, so how can I do this?
Got it :)
Absolute positioning to the rescue: http://jsfiddle.net/BbCQK/4/
a.thumbnail {
padding - bottom: 30px;
position: relative;
}.thumbnail.caption {
overflow: hidden;
white - space: nowrap;
position: absolute;
padding: 0;
bottom: 4px;
left: 4px;
right: 4px;
text - overflow: ellipsis;
}
After a long long while I had to do some frontend, and I have a annoying issue to resolve.
So basically I have 1900x1200 Div wrapper and while the whole thing looks pretty and centered on huge monitors, when I open it on a small/resolution monitor it isn't centered.
I would like the opening position to be in the middle of the whole thing regardless of my resolution.
Any ideas?
The whole thing is driving me nuts and I can't seem to be able to wrap my head around it. :(
(and I'm sorry if I don't make much sense, its 2:25 am here, I'm not a native speaker and my brain is fizzling out)
You could center the div through absolute positioning.
#DivWrapper {
width: 1900px;
height: 1200px;
position: absolute;
left: 50%;
margin-left: -950px;
}
Example: http://jsfiddle.net/AXenC/
If your interface is base on a smaller width than 1900px probably more like a 960 grid, you could center your background in in the body tag and center the wrapper(width of your content ie: 960 px) with the margin auto on the left and right.
body {
padding: 0;
margin: 0;
background: #aeaeae url(../images/back__v_1.jpg) 50%;
}
#wrapper {
width: 960px;
margin-right: auto;
margin-left: auto;
}