Skip to content

linear gradient in CSS not filling entire component #3092

@arthef

Description

@arthef

I am trying to style my component with CSS. This is a simple Label component, which I want to show with round corners and gradient filling in background.
Here is the CSS code:

ExampleLabel {
    cn1-derive: 'Label';
    text-align: left;
    color: white;
    padding-left: 15pt;
    border-radius: 10pt;
    border: 1pt solid transparent;
    background: linear-gradient(to bottom,
        rgba(231, 98, 0, 0.7) 0%,
        rgba(231, 98, 0, 0.9) 50%,
        rgba(231, 98, 0, 0.7) 100%
    );
}

Unfortunately, the gradient image generated by CSS compilation does not fill entire component. It appears to have fixed size and is copied over and over again to fill the component length as in attached image.
CleanShot 2020-05-04 at 16 18 51@2x

example Kotlin code to replicate the issue:
FormController code:

import com.codename1.charts.util.ColorUtil
import com.codename1.rad.controllers.Controller
import com.codename1.rad.controllers.FormController
import com.codename1.ui.CN
import com.codename1.ui.Container
import com.codename1.ui.Form
import com.codename1.ui.Label
import com.codename1.ui.layouts.BorderLayout

class TestController(parent: Controller) : FormController(parent) {
    private val mainForm: Form = Form("Example", BorderLayout())
    private val mainPanel: Container = Container(BorderLayout())

    init {
        val label = Label("Example Label")
        label.uiid = "ExampleLabel"
        mainPanel.add(CN.TOP, label)
        mainForm.add(CN.CENTER, mainPanel)
        setView(mainForm)
    }
}

Example ApplicationController code:

import com.codename1.rad.controllers.ApplicationController
import com.codename1.rad.controllers.ControllerEvent

@Suppress("unused")
open class ExampleApp: ApplicationController() {

    private var mainController: TestController? = null

    override fun actionPerformed(evt: ControllerEvent) {
        if (evt is StartEvent) {
            evt.consume()
            if (mainController == null) mainController = TestController(this)
            mainController!!.view.show()
        }
    }

}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions