Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: April 19, 2024, 2:42 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a "span" across the diagonal of a web-page?
#1
How to make a "span" across the diagonal of a web-page?
So, I have tried to add the "SOLD!" sign across the diagonal of my house-selling web-page. Here is what I tried.
HTML:
Code:
<span id="prodano">PRODANO! - SOLD!</span>
CSS:
Code:
#prodano
{
    background-color:#FF7777;
    color:#000077;
    font-size:36px;
    line-height:50px;
    position:fixed;
    display:none; /*Has not yet been sold!*/
    text-align:center;
}
JavaScript:
Code:
document.body.onresize=function()
    {
        var content=document.getElementById("content");
        var sirinaProzora=(window.innerWidth || //Moderni internetski preglednici
                            document.documentElement.clientWidth || //Internet Explorer 8
                            document.body.clientWidth //Internet Explorer 6
                            );
        var visinaProzora=(window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
        content.style.left=sirinaProzora/2-content.clientWidth/2+"px";
        var prodano=document.getElementById("prodano");
        var sirinaNatpisaProdano=Math.sqrt(Math.pow(sirinaProzora,2)+Math.pow(visinaProzora,2))+2*50;
        prodano.style.width=sirinaNatpisaProdano+"px";
        var nagibNatpisaProdano=Math.atan2(visinaProzora,sirinaProzora);
        prodano.style.transform="rotate("+nagibNatpisaProdano+"rad)";
        var yKoordinataNatpisa=(visinaProzora/2-Math.cos(nagibNatpisaProdano)*50);
        prodano.style.top=yKoordinataNatpisa+"px";
        prodano.style.left=-(Math.sin(nagibNatpisaProdano)*yKoordinataNatpisa)+"px";
    }
window.onresize=document.body.onresize;
window.onload=document.body.onresize;
I haven't yet managed to sell my house. My mother keeps insisting that the real price is 45'000 euros, even though I think houses like that are usually sold at around 30'000 euros.
But, anyway, what I have done now works in Firefox when run on my laptop, however, for some reason, it moves away from the diagonal as I resize the window. Can you find the error?
You can see my house-selling web-page here (the "display" of that "span" is set to "none" instead of to "block").
Reply
#2
RE: How to make a "span" across the diagonal of a web-page?
I am so glad I no longer have to deal with that nonsense. Back in the day, we used to have an initial script that determined the user-agent and version which then determined page content. This script grew and grew as versions of the commonest browsers proliferated. Eventually, we ditched the lot as unnecessary, and went with bog standard HTML for the user interface.

Alas, that variability will always remain the achilles heel of interpreted languages.

If it were me, I would have a handy copy of the lead image with a diagonal "SOLD" banner all prepped to swap in whenever. It would be a far more efficient use of time and eliminates all of the messing about with script compatibility. But then, I am old and not a little cynical.
Reply
#3
RE: How to make a "span" across the diagonal of a web-page?
Abaddon_ire Wrote:Alas, that variability will always remain the achilles heel of interpreted languages.
I don't care too much about compatibility with obsolete browsers, IE11 is the lowest I care about. I would like it to be legible in older browsers, that's all. I also think that the solution would result in the "SOLD" being in the middle of the screen in old browsers (which don't support CSS transform). I care much more about the layout not breaking when somebody resizes the screen or on the mobile devices.
Abaddon_ire Wrote:I would have a handy copy of the lead image with a diagonal "SOLD" banner all prepped to swap in whenever
I am not sure what you mean. If I insert a partly-transparent PNG on top of the web-page, the viewers won't be able to select neither the text in that PNG nor the text on the web-page.
Reply
#4
RE: How to make a "span" across the diagonal of a web-page?
(May 10, 2020 at 12:56 pm)FlatAssembler Wrote:
Abaddon_ire Wrote:Alas, that variability will always remain the achilles heel of interpreted languages.
I don't care too much about compatibility with obsolete browsers, IE11 is the lowest I care about. I would like it to be legible in older browsers, that's all. I also think that the solution would result in the "SOLD" being in the middle of the screen in old browsers (which don't support CSS transform). I care much more about the layout not breaking when somebody resizes the screen or on the mobile devices.
Abaddon_ire Wrote:I would have a handy copy of the lead image with a diagonal "SOLD" banner all prepped to swap in whenever
I am not sure what you mean. If I insert a partly-transparent PNG on top of the web-page, the viewers won't be able to select neither the text in that PNG nor the text on the web-page.

Simple. Prepare an image of the property with a honking great "sold" banner on it . When the property is actually sold, swap the images. I don't know how hard that is to do. Seems to me like something any moron can do. Seems to me like shedloads of morons can mange to do that all the time.

Somehow, it is beyond your skill set. For some reason. 

Do you need me to give you a worked example?
Reply
#5
RE: How to make a "span" across the diagonal of a web-page?
Abaddon_ire Wrote:Prepare an image of the property with a honking great "sold" banner on it .
Well, I have next to no GIMP skills, so that will take quite some time. Besides, I don't think it will look as nice.
Abaddon_ire Wrote:Seems to me like something any moron can do.
Well, I am studying computer science at the university, and I am studying a lot of it by myself, yet I don't know on the top of my head how I'd do that.
Reply
#6
RE: How to make a "span" across the diagonal of a web-page?
Anyway, here is the solution.
Reply
#7
RE: How to make a "span" across the diagonal of a web-page?
(May 26, 2020 at 6:08 am)FlatAssembler Wrote: Anyway, here is the solution.

Super, but so what. You could have had the same result in seconds in photoshop. Plus then, you wouldn't have to consider those awkward cross compatibility problems, nor the additional script overhead, nor the problem with so many people disabling javascript in this age of nigerian princes.
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  The Web SimpleCaveman 24 863 January 9, 2024 at 5:29 pm
Last Post: brewer
  [Serious] Coronavirus plotting on a web map WinterHold 6 1041 May 26, 2021 at 5:29 pm
Last Post: BrianSoddingBoru4
  bots and the change of the web. WinterHold 29 2387 June 20, 2020 at 11:26 am
Last Post: Abaddon_ire
  Solar System simulation: my latest web app. WinterHold 8 997 February 7, 2020 at 2:49 pm
Last Post: WinterHold
  [Serious] Multiple Sclerosis Map: my latest web project WinterHold 22 2941 October 4, 2019 at 10:02 am
Last Post: WinterHold
  Is front-end web development dying? WinterHold 18 1498 September 10, 2018 at 12:28 am
Last Post: KevinM1
  HELP! The Page Breaks in All My Documents Have Disappeared in Windows 2013 Rhondazvous 18 3855 January 9, 2018 at 8:44 pm
Last Post: Mermaid
  Welcome to McAfee Web Advisor popups... Rev. Rye 5 3039 June 4, 2017 at 5:31 pm
Last Post: Jackalope
  Question for Those of You Wwho Use Mobile Web Devices (iPhones, Smart Phones, etc.) Rhondazvous 26 4282 July 24, 2015 at 4:25 pm
Last Post: IATIA
  Advice Sought for Web Programming AFTT47 13 3269 April 4, 2015 at 10:41 pm
Last Post: bennyboy



Users browsing this thread: 1 Guest(s)